Bug Tracker

Opened 10 years ago

Closed 9 years ago

#14045 closed bug (migrated)

IE8: empty() leaks children if they were attached via DocumentFragment

Reported by: simon@… Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


empty() does not cleanly remove the children, which were attached via a DocumentFragment. The issue is a bug in IE8's (and below) Node.removeChild().

Running this fiddle in Sieve demonstrates the problem (IE8/sieve can't run jsfiddle, you have to create a local html):

Minimal test case: http://jsfiddle.net/cbQ2y/2/

The issue is resolved by using Node.removeNode(true). You can test the effect of removeNode in the fiddle by setting USE_DESTORY=true, reloading and pressing the button again (the elements no longer leak).

As this test case demonstrates, the issue can be resolved by using Node.removeNode(false) in IE8 instead of Node.removeChild; for example here: https://github.com/jquery/jquery/blob/1.9-stable/src/manipulation.js#L195

Additionally, the dojo source documents this IE8- bug right here: https://github.com/dojo/dojo/blob/master/dom-construct.js#L329

Change History (5)

comment:1 Changed 10 years ago by anonymous

fiddle updated: http://jsfiddle.net/cbQ2y/3/

(i had a line too much in it from testing)

comment:2 Changed 10 years ago by dmethvin

Component: unfiledmanipulation
Milestone: None1.next
Priority: undecidedlow
Status: newopen

Reference: http://msdn.microsoft.com/en-us/library/ie/ms536708(v=vs.85).aspx

We don't support document fragments as API inputs but it seems like this would occur for internal uses as well.

comment:3 Changed 10 years ago by simon@…

I always assumed that's supported but a closer look at the API proves me wrong.

This seems to be a general IE bug and not at all related to jquery. I was able to reproduce the leaking behavior with an even simpler case:

for (var i = 0; i<10; i++) {
	var frag = document.createDocumentFragment();
	var div = document.createElement('div');
	frag = null;

the leak is closed if I explicitly call removeNode on the fragments children (after each iteration):

while (c = frag.lastChild) {

comment:4 Changed 10 years ago by Timmy Willison

#14214 is a duplicate of this ticket.

comment:5 Changed 9 years ago by m_gol

Resolution: migrated
Status: openclosed
Note: See TracTickets for help on using tickets.