mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
CSS: Do not throw on frame elements in FF
IE9-10 throws on elements created in popups (see #14150), FF meanwhile throws on frame elements through "defaultView.getComputedStyle" (see #15098) Use "defaultView" if in the popup which would fix IE issue, use "window.getComputedStyle" which would fix FF issue. And everybody wins, except performance, but who cares right? Fixes #15098 Closes gh-1583
This commit is contained in:
parent
d837f119c3
commit
e488d985cf
@ -1,5 +1,12 @@
|
|||||||
define(function() {
|
define(function() {
|
||||||
return function( elem ) {
|
return function( elem ) {
|
||||||
|
// 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 elem.ownerDocument.defaultView.getComputedStyle( elem, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
return window.getComputedStyle( elem, null );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1068,4 +1068,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" );
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user