diff --git a/src/jqLite.js b/src/jqLite.js index b169d1b5acd5..e1231b61f731 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -715,12 +715,7 @@ forEach({ if (element.nodeType === 1) { var index = element.firstChild; forEach(new JQLite(node), function(child){ - if (index) { - element.insertBefore(child, index); - } else { - element.appendChild(child); - index = child; - } + element.insertBefore(child, index); }); } }, diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index f66305361104..92ccc2a80db9 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -1075,6 +1075,18 @@ describe('jqLite', function() { expect(root.prepend('abc')).toEqual(root); expect(root.html().toLowerCase()).toEqual('abctext'); }); + it('should prepend array to empty in the right order', function() { + var root = jqLite('