Skip to main content

Bug Tracker

Side navigation

#4386 closed bug (fixed)

Opened March 19, 2009 04:35PM UTC

Closed December 06, 2010 10:17PM UTC

Last modified March 21, 2012 12:15AM UTC

iframe body clone event IE

Reported by: bgrinstead Owned by: jitter
Priority: high Milestone: 1.5
Component: manipulation Version: 1.4.4
Keywords: explorer body clone Cc:
Blocked by: Blocking:
Description

I found some strange behavior in the clone event on the body element of an iframe. It only saves the first child node in the clone. If you clone an inner element, it works as expected (copies all of it's child nodes). I have been able to work around this behavior by changing the clone event back to how it was in 1.2.6 (with the owner document fix like in http://dev.jquery.com/ticket/2997).

Here is a test case that demonstrates the bug (works in firefox, broken in IE): http://jquery.nodnod.net/cases/257.

It certainly has to do with line 320 in jquery-1.3.2.js, but I haven't been able to fix it myself:

return jQuery.clean([html.replace(/ jQuery\\d+="(?:\\d+|null)"/g, "").replace(/^\\s*/, "")])[0];

Attachments (0)
Change History (8)

Changed April 10, 2009 03:00PM UTC by bgrinstead comment:1

OK, that test case website is overwriting the case I set up. I haven't heard any response in a few weeks, but I will go ahead and paste the case here. Hopefully someone can get a chance to look at this. Thanks!

<html>
<head></head>
<body>

<script type='text/javascript' src='jQuery-1.3.2.js'></script>
<script type='text/javascript'>

  $(function() {

     $("#go").click(function() {


       var $body = $(doc.body).clone();        
       var $p = $(doc.body).find("p").clone();
       
       // In IE only sees the first child of the body
       alert("Body inner html:\\n" + $body.html());

       // In IE sees all children of the p tag
       alert("Paragraph inner html:\\n" + $p.html());

     });

     var iframe = document.createElement("iframe");
     $("body").append(iframe);
     
     var doc = iframe.contentDocument || iframe.contentWindow.document;
     doc.open();
     doc.write("<span>Span 1</span><span>Span 2</span><p>Inside paragraph<span>Span 1</span><span>Span 2</span></p>");
     doc.close();

  });

</script>

<input id="go" value="go" type="button" />
</body>
</html>

Changed June 12, 2010 01:46PM UTC by dmethvin comment:2

component: unfiledmanipulation

Changed November 21, 2010 01:14AM UTC by jitter comment:3

keywords: explorer iframe cloneexplorer body clone
milestone: 1.41.5
priority: majorhigh
status: newopen
version: 1.3.21.4.4

Seems like bug in IE when cloning the body element.

test case

and proposal for a fix pull request

Changed November 21, 2010 10:05PM UTC by snover comment:4

owner: → jitter
status: openassigned

Changed December 06, 2010 10:17PM UTC by john comment:5

milestone: 1.51.4.5
resolution: → fixed
status: assignedclosed

Landed.

Changed December 12, 2010 07:51PM UTC by Colin Snover comment:6

Merge branch 'bug5566' into csnover-bug5566. Fixes #4386, #5566, #6997.

Conflicts:

src/manipulation.js

test/unit/manipulation.js

Changeset: 4fae75d575b20d887e4a273c7991c55f8821a62c

Changed January 14, 2011 10:20PM UTC by jitter comment:7

milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

Changed March 21, 2012 12:15AM UTC by mikesherov comment:8

interesting