From 92c840401271ba42543845a836f17c63aa28ef34 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Sat, 5 Nov 2011 23:04:09 -0400 Subject: Fixes jQuery.fragments cache and adds tests. Fixes #10682 --- test/unit/manipulation.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'test') 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("
  • "); + jQuery("
  • ?
  • "); + jQuery("
  • whip
  • "); + jQuery("
  • it
  • "); + jQuery("
  • good
  • "); + jQuery("
    "); + jQuery("
    "); + jQuery(""); + jQuery(""); + jQuery("
  • aaa
  • "); + jQuery(""); + jQuery("

    arf

    nnn
    "); + jQuery("

    dog

    ?
    "); + jQuery(""); + + equal( fragmentCacheSize(), 12, "12 entries exist in jQuery.fragments, 1" ); + + jQuery.each( [ + "", + "
    • ?
    ", + "

    dog

    ?
    ", + "" + ], 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 -- cgit v1.2.3