From 92c840401271ba42543845a836f17c63aa28ef34 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Sat, 5 Nov 2011 23:04:09 -0400 Subject: [PATCH 1/2] Fixes jQuery.fragments cache and adds tests. Fixes #10682 --- src/manipulation.js | 2 +- test/unit/manipulation.js | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/manipulation.js b/src/manipulation.js index 6e77e2daa..134756544 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -480,7 +480,7 @@ jQuery.buildFragment = function( args, nodes, scripts ) { // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document && first.charAt(0) === "<" && !rnocache.test( first ) && - (jQuery.support.checkClone || !rchecked.test( first )) && + (jQuery.support.checkClone || !rchecked.test( first )) || (!jQuery.support.unknownElems && rnoshimcache.test( first )) ) { cacheable = true; 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 From 0ce2d5e1cb4c2484154a916f3d1876759a59c032 Mon Sep 17 00:00:00 2001 From: timmywil Date: Tue, 8 Nov 2011 00:06:38 -0500 Subject: [PATCH 2/2] Update Sizzle --- src/sizzle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sizzle b/src/sizzle index 5d3cc64e7..d4e5c22e7 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit 5d3cc64e732631cde3924a3deaaf4a282feef1c5 +Subproject commit d4e5c22e7ee8aa5751fc8d4d4f21d7ed5ff04a49