aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/var/getStyles.js
blob: 9dc4298d562eee77935f39f24042f021ffd9896e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export function getStyles( elem ) {

	// Support: IE <=11+ (trac-14150)
	// In IE popup's `window` is the opener window which makes `window.getComputedStyle( elem )`
	// break. Using `elem.ownerDocument.defaultView` avoids the issue.
	var view = elem.ownerDocument.defaultView;

	// `document.implementation.createHTMLDocument( "" )` has a `null` `defaultView`
	// property; check `defaultView` truthiness to fallback to window in such a case.
	if ( !view ) {
		view = window;
	}

	return view.getComputedStyle( elem );
}