mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Traversing: Fix contents()
on <object>
s with children in IE
The original fix didn't account for the fact that in IE `<object>` elements
with no `data` attribute have an object `contentDocument`. The fix leverages
the fact that this special object has a null prototype.
(cherry-picked from ccbd6b9342
)
Closes gh-4390
Ref gh-4384
Ref gh-4385
This commit is contained in:
parent
42badf3460
commit
90f78b9aab
@ -1,5 +1,6 @@
|
|||||||
define( [
|
define( [
|
||||||
"./core",
|
"./core",
|
||||||
|
"./var/getProto",
|
||||||
"./var/indexOf",
|
"./var/indexOf",
|
||||||
"./traversing/var/dir",
|
"./traversing/var/dir",
|
||||||
"./traversing/var/siblings",
|
"./traversing/var/siblings",
|
||||||
@ -9,7 +10,7 @@ define( [
|
|||||||
"./core/init",
|
"./core/init",
|
||||||
"./traversing/findFilter",
|
"./traversing/findFilter",
|
||||||
"./selector"
|
"./selector"
|
||||||
], function( jQuery, indexOf, dir, siblings, rneedsContext, nodeName ) {
|
], function( jQuery, getProto, indexOf, dir, siblings, rneedsContext, nodeName ) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -145,7 +146,13 @@ jQuery.each( {
|
|||||||
return siblings( elem.firstChild );
|
return siblings( elem.firstChild );
|
||||||
},
|
},
|
||||||
contents: function( elem ) {
|
contents: function( elem ) {
|
||||||
if ( elem.contentDocument != null ) {
|
if ( elem.contentDocument != null &&
|
||||||
|
|
||||||
|
// Support: IE 11+
|
||||||
|
// <object> elements with no `data` attribute has an object
|
||||||
|
// `contentDocument` with a `null` prototype.
|
||||||
|
getProto( elem.contentDocument ) ) {
|
||||||
|
|
||||||
return elem.contentDocument;
|
return elem.contentDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user