diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-05-08 10:12:36 +0200 |
---|---|---|
committer | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-05-08 11:08:14 +0200 |
commit | 90f78b9aab9c99ff3ffcccb1db602670e9707fa0 (patch) | |
tree | 392e9177fc5a2aceb308670d91bfe05cf7d85fac /src | |
parent | 42badf34607092fd754a18f5b71e9b08457f982a (diff) | |
download | jquery-90f78b9aab9c99ff3ffcccb1db602670e9707fa0.tar.gz jquery-90f78b9aab9c99ff3ffcccb1db602670e9707fa0.zip |
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 ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3)
Closes gh-4390
Ref gh-4384
Ref gh-4385
Diffstat (limited to 'src')
-rw-r--r-- | src/traversing.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/traversing.js b/src/traversing.js index 25843ee8c..afbecc4f4 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -1,5 +1,6 @@ define( [ "./core", + "./var/getProto", "./var/indexOf", "./traversing/var/dir", "./traversing/var/siblings", @@ -9,7 +10,7 @@ define( [ "./core/init", "./traversing/findFilter", "./selector" -], function( jQuery, indexOf, dir, siblings, rneedsContext, nodeName ) { +], function( jQuery, getProto, indexOf, dir, siblings, rneedsContext, nodeName ) { "use strict"; @@ -145,7 +146,13 @@ jQuery.each( { return siblings( elem.firstChild ); }, 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; } |