mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-28 23:28:16 +00:00
fix(jqLite): prepend array in correct order
Match jQuery behavior when prepending array into empty element
This commit is contained in:
parent
3ffddad100
commit
fd87eb0ca5
2 changed files with 13 additions and 6 deletions
|
|
@ -715,12 +715,7 @@ forEach({
|
||||||
if (element.nodeType === 1) {
|
if (element.nodeType === 1) {
|
||||||
var index = element.firstChild;
|
var index = element.firstChild;
|
||||||
forEach(new JQLite(node), function(child){
|
forEach(new JQLite(node), function(child){
|
||||||
if (index) {
|
element.insertBefore(child, index);
|
||||||
element.insertBefore(child, index);
|
|
||||||
} else {
|
|
||||||
element.appendChild(child);
|
|
||||||
index = child;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1075,6 +1075,18 @@ describe('jqLite', function() {
|
||||||
expect(root.prepend('abc')).toEqual(root);
|
expect(root.prepend('abc')).toEqual(root);
|
||||||
expect(root.html().toLowerCase()).toEqual('abctext');
|
expect(root.html().toLowerCase()).toEqual('abctext');
|
||||||
});
|
});
|
||||||
|
it('should prepend array to empty in the right order', function() {
|
||||||
|
var root = jqLite('<div>');
|
||||||
|
expect(root.prepend([a, b, c])).toBe(root);
|
||||||
|
expect(sortedHtml(root)).
|
||||||
|
toBe('<div><div>A</div><div>B</div><div>C</div></div>');
|
||||||
|
});
|
||||||
|
it('should prepend array to content in the right order', function() {
|
||||||
|
var root = jqLite('<div>text</div>');
|
||||||
|
expect(root.prepend([a, b, c])).toBe(root);
|
||||||
|
expect(sortedHtml(root)).
|
||||||
|
toBe('<div><div>A</div><div>B</div><div>C</div>text</div>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue