Bug Tracker

Modify

Ticket #4386 (closed bug: fixed)

Opened 5 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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];

Change History

comment:1 Changed 5 years ago by bgrinstead

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>

comment:2 Changed 4 years ago by dmethvin

  • Component changed from unfiled to manipulation

comment:3 Changed 3 years ago by jitter

  • Keywords body added; iframe removed
  • Priority changed from major to high
  • Version changed from 1.3.2 to 1.4.4
  • Status changed from new to open
  • Milestone changed from 1.4 to 1.5

Seems like bug in IE when cloning the body element.

 test case

and proposal for a fix  pull request

comment:4 Changed 3 years ago by snover

  • Owner set to jitter
  • Status changed from open to assigned

comment:5 Changed 3 years ago by john

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from 1.5 to 1.4.5

Landed.

comment:6 Changed 3 years ago by Colin Snover

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

Conflicts:

src/manipulation.js test/unit/manipulation.js

Changeset: 4fae75d575b20d887e4a273c7991c55f8821a62c

comment:7 Changed 3 years ago by jitter

  • Milestone changed from 1.4.5 to 1.5

Move fixed tickets to appropriate milestone

comment:10 Changed 2 years ago by mikesherov

interesting

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.