Side navigation
#14045 closed bug (migrated)
Opened June 20, 2013 08:54AM UTC
Closed October 21, 2014 12:12AM UTC
IE8: empty() leaks children if they were attached via DocumentFragment
| Reported by: | simon@nekapuzer.at | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | manipulation | Version: | 1.9.1 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
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/
- press the button
- see that in Sieve the 10 elements are still in memory ('orphaned') althought the container was emptied: http://i.imgur.com/q2rPcUW.png
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
Attachments (0)
Change History (5)
Changed June 20, 2013 08:57AM UTC by comment:1
Changed June 23, 2013 04:40PM UTC by comment:2
| component: | unfiled → manipulation |
|---|---|
| milestone: | None → 1.next |
| priority: | undecided → low |
| status: | new → open |
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.
Changed June 25, 2013 09:24AM UTC by comment:3
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.appendChild(div);
frag = null;
}
the leak is closed if I explicitly call removeNode on the fragments children (after each iteration):
while (c = frag.lastChild) {
c.removeNode(false)
}
Changed October 21, 2014 12:12AM UTC by comment:5
| resolution: | → migrated |
|---|---|
| status: | open → closed |
Migrated to https://github.com/jquery/jquery/issues/1745
fiddle updated: http://jsfiddle.net/cbQ2y/3/
(i had a line too much in it from testing)