Ticket #4386 (closed bug: fixed)
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: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
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 2 years ago by jitter
- Milestone changed from 1.4.5 to 1.5
Move fixed tickets to appropriate milestone
comment:10 Changed 15 months 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.

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>