Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 96ed9ff

Browse files
committed
fix(jqLite): support append on document fragment
previously jquery didn't support append on this node type, now it does (since 1.8.x) so I'm adding this to jqlite as well.
1 parent b9a9f91 commit 96ed9ff

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/jqLite.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,9 @@ forEach({
659659

660660
append: function(element, node) {
661661
forEach(new JQLite(node), function(child){
662-
if (element.nodeType === 1)
662+
if (element.nodeType === 1 || element.nodeType === 11) {
663663
element.appendChild(child);
664+
}
664665
});
665666
},
666667

test/jqLiteSpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,14 @@ describe('jqLite', function() {
955955
expect(root.append('text')).toEqual(root);
956956
expect(root.html()).toEqual('text');
957957
});
958-
it('should not append anything if parent node is not of type element', function() {
958+
it('should append to document fragment', function() {
959959
var root = jqLite(document.createDocumentFragment());
960960
expect(root.append('<p>foo</p>')).toBe(root);
961+
expect(root.children().length).toBe(1);
962+
});
963+
it('should not append anything if parent node is not of type element or docfrag', function() {
964+
var root = jqLite('<p>some text node</p>').contents();
965+
expect(root.append('<p>foo</p>')).toBe(root);
961966
expect(root.children().length).toBe(0);
962967
});
963968
});

0 commit comments

Comments
 (0)