Bug Tracker

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#10324 closed bug (fixed)

Clone does not copy innerHTML of object element in IE9

Reported by: lukasbob@… Owned by: Rick Waldron
Priority: blocker Milestone: 1.8
Component: manipulation Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

Description

In IE9, the contents of object elements is not copied to the cloned element when using .clone().

<object><param name="test" value="test"></object>
<script>
$(function() {
    var elm = $("object");
    var clone = elm.clone();
    alert(elm.html() === clone.html());
});
</script>

The above example on JSFiddle: http://jsfiddle.net/lukasbob/cSFMg/

Alerts true in Chrome, Firefox, IE < 9, Safari

Behaviour in previous jQuery versions:

  • 1.5.2, 1.6.2: Raises an error: "Error: Unable to get value of the property 'nodeType': object is null or undefined"
  • 1.4.4: Works as expected.

Change History (16)

comment:1 Changed 12 years ago by Timmy Willison

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

comment:2 Changed 12 years ago by Timmy Willison

Priority: lowhigh
Version: 1.6.31.6.4

comment:3 Changed 11 years ago by michael.heuberger@…

I confirm, I'm having this bug too. Happens on IE9, not on Firefox when cloning an object containing Flash wrapped by SWFObject.

Any chance this can be solved before the next release?

comment:4 Changed 11 years ago by michael.heuberger@…

I forgot to mention that this error is thrown + shown in the IE console when cloning such a flash object: "Unable to get value of the property \'nodeType\': object is null or undefined" String

comment:5 Changed 11 years ago by Rick Waldron

Owner: set to Rick Waldron
Priority: highblocker
Status: openassigned

comment:6 Changed 11 years ago by Rick Waldron

Re-confirmed: http://jsfiddle.net/rwaldron/m9UVM/

Patch to follow

comment:8 Changed 11 years ago by michael.heuberger@…

Fantastic. Will you include that changeset in the next minor release?

comment:9 Changed 11 years ago by dmethvin

It's not assigned to a release at this point, but we just finished 1.7.2 so it will likely be a few months.

comment:10 in reply to:  9 Changed 11 years ago by michael.heuberger@…

Replying to dmethvin:

It's not assigned to a release at this point, but we just finished 1.7.2 so it will likely be a few months.

A few months? Ouch!

Is there a way I could deploy this bugfix right now on the site I'm working on?

comment:11 Changed 11 years ago by Rick Waldron waldron.rick@…

Resolution: fixed
Status: assignedclosed

Ensure innerHTML of src/dest clone nodes is correctly set. Fixes #10324

Signed-off-by: Rick Waldron waldron.rick@… <waldron.rick@…>

Changeset: 2795a8390c1986200bf4e00158dbf3ad2da8d898

comment:12 Changed 11 years ago by Rick Waldron

Fix #10324. IE9 fumbles the innerHTML on object elements.

Changeset: 62a4c8450367a8f1ef3a6ae3c5c08c7a025113c2

comment:13 Changed 11 years ago by dmethvin

Milestone: 1.next1.8

comment:14 Changed 11 years ago by michael.heuberger@…

Looks like the bug is still there, in jQuery 1.8 :(

comment:15 Changed 11 years ago by dmethvin

As far as we can tell, it is just not possible to clone the contents of an object tag with perfect fidelity in IE9. We are, however, trying to clone the essential contents. What exactly is failing? Can we have a test case and a specific description of the impact?

comment:16 Changed 11 years ago by michael.heuberger@…

Difficult to say what exactly is failing.

All I can see is this error message in the IE console:

SCRIPT5007: Unable to get value of the property 'SetReturnValue': object is null or undefined 
add, line 1 character 1

It happens when you record again a video comment under: https://www.seeflow.co.nz/contact/action/add/

First just record something then click on stop + view, then record it again.

Currently I'm having this code:

  showPreview: function() {
    this.tikatoyRecorderClone = $('#tikatoyRecorder').clone(true);
    $('#tikatoyRecorder').remove();
    
    if (this.tikatoyPreviewClone)
      $('#tikatoyHolder').html(this.tikatoyPreviewClone);
    
    $('#tikatoyPreview').show();
  },

  showRecorder: function() {
    this.tikatoyPreviewClone = $('#tikatoyPreview').clone(true);
    $('#tikatoyPreview').remove();
    
    $('#tikatoyHolder').html(this.tikatoyRecorderClone);
    
    $('#tikatoyRecorder').show();
  },

Basically I'm cloning and reinserting containers that contain Flash objects. The call to show() looks like unnecessary but it's needed to call a callback function inside the Flash object. So that it initiates something else.

Hope that helps?

Michael

Note: See TracTickets for help on using tickets.