From 96ed9ff59a454486c88bdf92ad9d28ab8864b85e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 24 Nov 2012 01:34:01 +0100 Subject: 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. --- src/jqLite.js | 3 ++- test/jqLiteSpec.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jqLite.js b/src/jqLite.js index 26be5977..38bf9437 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -659,8 +659,9 @@ forEach({ append: function(element, node) { forEach(new JQLite(node), function(child){ - if (element.nodeType === 1) + if (element.nodeType === 1 || element.nodeType === 11) { element.appendChild(child); + } }); }, diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 76a2c5a8..01f9b9ae 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -955,9 +955,14 @@ 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() { + it('should append to document fragment', function() { var root = jqLite(document.createDocumentFragment()); expect(root.append('
foo
')).toBe(root); + expect(root.children().length).toBe(1); + }); + it('should not append anything if parent node is not of type element or docfrag', function() { + var root = jqLite('some text node
').contents(); + expect(root.append('foo
')).toBe(root); expect(root.children().length).toBe(0); }); }); -- cgit v1.2.3