Skip to content
Permalink
Browse files

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

  • Loading branch information...
rwaldron authored and dmethvin committed Apr 11, 2012
2 parents 0e2642d + 2795a83 commit 62a4c8450367a8f1ef3a6ae3c5c08c7a025113c2
Showing with 19 additions and 1 deletion.
  1. +8 −0 src/manipulation.js
  2. +1 −0 test/index.html
  3. +10 −1 test/unit/manipulation.js
@@ -423,6 +423,14 @@ function cloneFixAttributes( src, dest ) {
if ( nodeName === "object" ) {
dest.outerHTML = src.outerHTML;

// This path appears unavoidable for IE9. When cloning an object
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
dest.innerHTML = src.innerHTML;
}

} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
// IE6-8 fails to persist the checked state of a cloned checkbox
// or radio button. Worse, IE6-7 fail to give the cloned element
@@ -135,6 +135,7 @@ <h2 id="qunit-userAgent"></h2>
<param name="p1" value="x1" />
<param name="p2" value="x2" />
</object>
<object id="object2"><param name="test" value="test"></param></object>​

<span id="台北Táiběi"></span>
<span id="台北" lang="中文"></span>
@@ -568,6 +568,15 @@ test("IE8 serialization bug", function () {
equal( wrapper.children("link").length, 1, "Link elements are insertable with .html()");
});

test("html() object element #10324", function() {
expect( 1 );

var object = jQuery("#object2"),
clone = object.clone();

equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
});

test("append(xml)", function() {
expect( 1 );

@@ -1771,4 +1780,4 @@ test("Guard against exceptions when clearing safeChildNodes", function() {
} catch(e) {}

ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" );
});
});

6 comments on commit 62a4c84

@Krinkle

This comment has been minimized.

Copy link
Member

replied Apr 11, 2012

Since this commit the unit tests FAIL in all browsers:

Looks like the test "Name selector non-input ([name=test])" of the selector module is failing. Duplicate name attribute.

@rwaldron

This comment has been minimized.

Copy link
Member Author

replied Apr 11, 2012

Weird, I'll take a look at this in AM

@rwaldron

This comment has been minimized.

Copy link
Member Author

replied Apr 11, 2012

Looks like the patch itself is not related, just the fixture

@Krinkle

This comment has been minimized.

Copy link
Member

replied Apr 11, 2012

@dmethvin saw it happening on IRC in #jquery-dev, he started fixing it in 0f827c8. However IE7 and IE8 are still failing after that commit, different failure:

test 5: selector: element
assertion 7:    equal( jQuery("param", "#object1").length, 2, "Object/param as context" );
Expected: 2
Result: 3
@dmethvin

This comment has been minimized.

Copy link
Member

replied Apr 11, 2012

Looks like IE7/8 are failing on jQuery("param", "#object1") and finding the param in #object2 as well.

@rwaldron

This comment has been minimized.

Copy link
Member Author

replied Apr 11, 2012

Fixed here: #735

Please sign in to comment.
You can’t perform that action at this time.