Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 62a4c84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/manipulation.js
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Expand Up @@ -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>
Expand Down
11 changes: 10 additions & 1 deletion test/unit/manipulation.js
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rwaldron
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Krinkle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rwaldron
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: #735

Please sign in to comment.