Skip to main content

Bug Tracker

Side navigation

#10324 closed bug (fixed)

Opened September 21, 2011 10:46AM UTC

Closed May 16, 2012 06:04PM UTC

Last modified August 23, 2012 03:06AM UTC

Clone does not copy innerHTML of object element in IE9

Reported by: lukasbob@gmail.com Owned by: rwaldron
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.
Attachments (0)
Change History (16)

Changed September 21, 2011 01:26PM UTC by timmywil comment:1

component: unfiledmanipulation
milestone: None1.next
priority: undecidedlow
status: newopen

Changed September 21, 2011 01:27PM UTC by timmywil comment:2

priority: lowhigh
version: 1.6.31.6.4

Changed March 23, 2012 01:51AM UTC by michael.heuberger@binarykitchen.com comment:3

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?

Changed March 23, 2012 01:54AM UTC by michael.heuberger@binarykitchen.com comment:4

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

Changed March 23, 2012 02:17PM UTC by rwaldron comment:5

owner: → rwaldron
priority: highblocker
status: openassigned

Changed March 23, 2012 02:20PM UTC by rwaldron comment:6

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

Patch to follow

Changed March 23, 2012 03:55PM UTC by rwaldron comment:7

Changed March 24, 2012 03:07AM UTC by michael.heuberger@binarykitchen.com comment:8

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

Changed March 24, 2012 03:28AM UTC by dmethvin comment:9

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.

Changed March 30, 2012 01:58AM UTC by michael.heuberger@binarykitchen.com comment:10

Replying to [comment:9 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?

Changed May 16, 2012 06:04PM UTC by Rick Waldron waldron.rick@gmail.com comment:11

resolution: → fixed
status: assignedclosed

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

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

Changeset: 2795a8390c1986200bf4e00158dbf3ad2da8d898

Changed May 16, 2012 06:04PM UTC by Rick Waldron comment:12

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

Changeset: 62a4c8450367a8f1ef3a6ae3c5c08c7a025113c2

Changed May 16, 2012 06:11PM UTC by dmethvin comment:13

milestone: 1.next1.8

Changed August 15, 2012 03:22AM UTC by michael.heuberger@binarykitchen.com comment:14

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

Changed August 15, 2012 03:24AM UTC by dmethvin comment:15

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?

Changed August 23, 2012 03:06AM UTC by michael.heuberger@binarykitchen.com comment:16

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