diff options
| -rw-r--r-- | src/jqLite.js | 3 | ||||
| -rw-r--r-- | test/jqLiteSpec.js | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/jqLite.js b/src/jqLite.js index d16ce19e..6539aaab 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -342,7 +342,8 @@ forEach({ append: function(element, node) { forEach(new JQLite(node), function(child){ - element.appendChild(child); + if (element.nodeType === 1) + element.appendChild(child); }); }, diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 2fc670ce..e566b1fe 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -299,6 +299,11 @@ describe('jqLite', function(){ expect(root.append('text')).toEqual(root); expect(root.html()).toEqual('text'); }); + it('should not append anything if parent node is not of type element', function() { + var root = jqLite(document.createDocumentFragment()); + expect(root.append('<p>foo</p>')).toBe(root); + expect(root.children().length).toBe(0); + }); }); describe('remove', function(){ it('should remove', function(){ |
