Bug Tracker

Modify

Ticket #10324 (closed bug: fixed)

Opened 3 years ago

Last modified 20 months ago

Clone does not copy innerHTML of object element in IE9

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

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

comment:1 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to manipulation
  • Milestone changed from None to 1.next

comment:2 Changed 3 years ago by timmywil

  • Priority changed from low to high
  • Version changed from 1.6.3 to 1.6.4

comment:3 Changed 2 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 2 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 2 years ago by rwaldron

  • Owner set to rwaldron
  • Priority changed from high to blocker
  • Status changed from open to assigned

comment:6 Changed 2 years ago by rwaldron

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

Patch to follow

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

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

comment:9 follow-up: ↓ 10 Changed 2 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 2 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 2 years ago by Rick Waldron waldron.rick@…

  • Status changed from assigned to closed
  • Resolution set to fixed

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 2 years ago by Rick Waldron

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

Changeset: 62a4c8450367a8f1ef3a6ae3c5c08c7a025113c2

comment:13 Changed 2 years ago by dmethvin

  • Milestone changed from 1.next to 1.8

comment:14 Changed 21 months ago by michael.heuberger@…

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

comment:15 Changed 21 months 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 20 months 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

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.