Bug Tracker

Modify

Ticket #11669 (closed bug: worksforme)

Opened 13 months ago

Last modified 13 months ago

Cache in jQuery.buildFragment has a bug

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

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;

Change History

comment:1 Changed 13 months ago by snandy

Oh, I see. JQuery specially in the second to cache that was avoid memory takes too much. This is not a bug, Please closeed.

comment:2 Changed 13 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to worksforme

Closed per OP request.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.