From 13449a99b2b279a7ae6401b8373d20504362213d Mon Sep 17 00:00:00 2001 From: Paul Ramos Date: Tue, 4 Dec 2012 21:30:37 -0500 Subject: [PATCH] Fix #11989. Remove fragment cache, moving to jquery-compat. Close gh-1052. --- src/core.js | 3 +- src/manipulation.js | 43 +++++--------------------- test/unit/manipulation.js | 64 --------------------------------------- 3 files changed, 9 insertions(+), 101 deletions(-) diff --git a/src/core.js b/src/core.js index eee810070..22b56ce5d 100644 --- a/src/core.js +++ b/src/core.js @@ -497,8 +497,7 @@ jQuery.extend({ if ( scripts ) { jQuery( scripts ).remove(); } - return jQuery.merge( [], - ( parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment ).childNodes ); + return jQuery.merge( [], parsed.childNodes ); }, parseJSON: function( data ) { diff --git a/src/manipulation.js b/src/manipulation.js index f215d5a8c..6cde99404 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -22,7 +22,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca rtbody = / or elements in a fragment - // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache - // 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 && context === document && - first.charAt(0) === "<" && !rnocache.test( first ) && - (jQuery.support.checkClone || !rchecked.test( first )) && - (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { - - // Mark cacheable and look for a hit - cacheable = true; - fragment = jQuery.fragments[ first ]; - cachehit = fragment !== undefined; - } - - if ( !fragment ) { - fragment = context.createDocumentFragment(); - jQuery.clean( args, context, fragment, scripts ); + fragment = context.createDocumentFragment(); + jQuery.clean( args, context, fragment, scripts ); - // Update the cache, but only store false - // unless this is a second parsing of the same content - if ( cacheable ) { - jQuery.fragments[ first ] = cachehit && fragment; - } - } - - return { fragment: fragment, cacheable: cacheable }; + return fragment; }; -jQuery.fragments = {}; - jQuery.each({ appendTo: "append", prependTo: "prepend", diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 2ac75e53b..788c75bf0 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -689,21 +689,6 @@ if ( jQuery.css ) { }); } -test( "html5 clone() cannot use the fragment cache in IE (#6485)", function() { - - expect( 1 ); - - var clone; - - jQuery("
").appendTo("#qunit-fixture"); - - clone = jQuery("article").clone(); - - jQuery("#qunit-fixture").append( clone ); - - equal( jQuery("aside").length, 2, "clone()ing HTML5 elems does not collapse them" ); -}); - test( "html(String) with HTML5 (Bug #6485)", function() { expect( 2 ); @@ -2112,55 +2097,6 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() { $clone.unbind("click"); }); -test( "jQuery.fragments cache expectations", function() { - - expect( 10 ); - - jQuery.fragments = {}; - - function fragmentCacheSize() { - var c, - n = 0; - - 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" ); -}); - test( "Guard against exceptions when clearing safeChildNodes", function() { expect( 1 ); -- 2.39.5