Skip to content

Commit

Permalink
CSS: make the getStyles function more readable
Browse files Browse the repository at this point in the history
The new version is not only simpler to read but also smaller
by 6 bytes gzipped.

Closes gh-2393
  • Loading branch information
mr21 authored and mgol committed Jun 25, 2015
1 parent 5153b53 commit 3a0d582
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/css/var/getStyles.js
Original file line number Diff line number Diff line change
@@ -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 );
};
});

0 comments on commit 3a0d582

Please sign in to comment.