aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/css/curCSS.js9
-rw-r--r--test/unit/css.js23
2 files changed, 31 insertions, 1 deletions
diff --git a/src/css/curCSS.js b/src/css/curCSS.js
index 1f3b73428..9ab4f1126 100644
--- a/src/css/curCSS.js
+++ b/src/css/curCSS.js
@@ -11,7 +11,14 @@ var getStyles, curCSS,
if ( window.getComputedStyle ) {
getStyles = function( elem ) {
- return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
+ // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
+ // IE throws on elements created in popups
+ // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
+ if ( elem.ownerDocument.defaultView.opener ) {
+ return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
+ }
+
+ return window.getComputedStyle( elem, null );
};
curCSS = function( elem, name, computed ) {
diff --git a/test/unit/css.js b/test/unit/css.js
index 28bc684ef..2051a2d00 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1126,4 +1126,27 @@ test( "show() after hide() should always set display to initial value (#14750)",
});
}
})();
+
+test( "Do not throw on frame elements from css method (#15098)", 1, function() {
+ var frameWin, frameDoc,
+ frameElement = document.createElement( "iframe" ),
+ frameWrapDiv = document.createElement( "div" );
+
+ frameWrapDiv.appendChild( frameElement );
+ document.body.appendChild( frameWrapDiv );
+ frameWin = frameElement.contentWindow;
+ frameDoc = frameWin.document;
+ frameDoc.open();
+ frameDoc.write( "<!doctype html><html><body><div>Hi</div></body></html>" );
+ frameDoc.close();
+
+ frameWrapDiv.style.display = "none";
+
+ try {
+ jQuery( frameDoc.body ).css( "direction" );
+ ok( true, "It didn't throw" );
+ } catch ( _ ) {
+ ok( false, "It did throw" );
+ }
+});
}