Skip to main content

Bug Tracker

Side navigation

#11669 closed bug (worksforme)

Opened April 28, 2012 10:10AM UTC

Closed April 28, 2012 02:35PM UTC

Cache in jQuery.buildFragment has a bug

Reported by: snandy Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery.buildFragment will cache the same fragment in jQuery.fragments.But the time is wrong.

For example:

var str   = '<i>hi</i>';
var $body = $(document.body);
$body.append(str);
$body.append(str);

When the second call .append(str) should use the cache of jQuery.fragments. But at this time jQuery.fragments of '<i>hi</i>' is 1 but not fragment.

jQuery.fragments["<i>hi</i>"] = 1;

So, until the third call to build '<i>hi</i>' fragment began to use the cache. This is the wrong implementation.

Modify the following:

delete the code

cacheresults = jQuery.fragments[ first ];
if ( cacheresults && cacheresults !== 1 ) {
	fragment = cacheresults;
}

use the following to replace

fragment = jQuery.fragments[ first ];

delete the code

jQuery.fragments[ first ] = cacheresults ? fragment : 1;

use the following to replace

jQuery.fragments[ first ] = fragment;
Attachments (0)
Change History (2)

Changed April 28, 2012 12:50PM UTC by snandy comment:1

Oh, I see.

JQuery specially in the second to cache that was avoid memory takes too much.

This is not a bug, Please closeed.

Changed April 28, 2012 02:35PM UTC by dmethvin comment:2

resolution: → worksforme
status: newclosed

Closed per OP request.