diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2011-11-05 23:04:09 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2011-11-05 23:06:53 -0400 |
commit | 92c840401271ba42543845a836f17c63aa28ef34 (patch) | |
tree | cbe2c33e9e7f2f75bb3ff2d6718c55538bbb6ebc /test | |
parent | 8380e12ab4aa3241a1b365f86c121d27a5ea65a5 (diff) | |
download | jquery-92c840401271ba42543845a836f17c63aa28ef34.tar.gz jquery-92c840401271ba42543845a836f17c63aa28ef34.zip |
Fixes jQuery.fragments cache and adds tests. Fixes #10682
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/manipulation.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e8c7cd72a..59dc16225 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1531,3 +1531,51 @@ test("jQuery.clone - no exceptions for object elements #9587", function() { ok( false, e.message ); } }); + +test("jQuery.fragments cache expectations", function() { + + expect( 10 ); + + jQuery.fragments = {}; + + function fragmentCacheSize() { + var n = 0, c; + + for ( c in jQuery.fragments ) { + n++; + } + return n; + } + + jQuery("<li></li>"); + jQuery("<li>?</li>"); + jQuery("<li>whip</li>"); + jQuery("<li>it</li>"); + jQuery("<li>good</li>"); + jQuery("<div></div>"); + jQuery("<div><div><span></span></div></div>"); + jQuery("<tr><td></td></tr>"); + jQuery("<tr><td></tr>"); + jQuery("<li>aaa</li>"); + jQuery("<ul><li>?</li></ul>"); + jQuery("<div><p>arf</p>nnn</div>"); + jQuery("<div><p>dog</p>?</div>"); + jQuery("<span><span>"); + + equal( fragmentCacheSize(), 12, "12 entries exist in jQuery.fragments, 1" ); + + jQuery.each( [ + "<tr><td></td></tr>", + "<ul><li>?</li></ul>", + "<div><p>dog</p>?</div>", + "<span><span>" + ], function( i, frag ) { + + jQuery( frag ); + + equal( jQuery.fragments[ frag ].nodeType, 11, "Second call with " + frag + " creates a cached DocumentFragment, has nodeType 11" ); + ok( jQuery.fragments[ frag ].childNodes.length, "Second call with " + frag + " creates a cached DocumentFragment, has childNodes with length" ); + }); + + equal( fragmentCacheSize(), 12, "12 entries exist in jQuery.fragments, 2" ); +});
\ No newline at end of file |