]> source.dussan.org Git - jquery.git/commitdiff
CSS: make the getStyles function more readable
authorThomas Tortorini <thomastortorini@gmail.com>
Sun, 14 Jun 2015 21:58:44 +0000 (23:58 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Thu, 25 Jun 2015 00:48:35 +0000 (02:48 +0200)
The new version is not only simpler to read but also smaller
by 6 bytes gzipped.

Closes gh-2393

src/css/var/getStyles.js

index 0d1d51af627f0229d78744d2e735415eff6711f1..31dfc298ea63df8233febdf232b1ad391a315b55 100644 (file)
@@ -1,12 +1,15 @@
 define(function() {
        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 );
+               var view = elem.ownerDocument.defaultView;
+
+               if ( !view.opener ) {
+                       view = window;
                }
 
-               return window.getComputedStyle( elem );
+               return view.getComputedStyle( elem );
        };
 });