computed-styles
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -9,2 +9,5 @@ CHANGELOG | ||
## 1.1.2 (2015-10-28) | ||
* Fix for IE11 | ||
## 1.1.1 (2015-10-28) | ||
@@ -11,0 +14,0 @@ * Fix for undefined values |
{ | ||
"name": "computed-styles", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Get the computed styles of a DOM element in a cross browser consistent manner", | ||
@@ -18,5 +18,7 @@ "main": "lib/index.js", | ||
"watch": "watch 'npm run build' src test", | ||
"test": "babel-node test/jsdom-index.js | tspec", | ||
"test": "npm run zuul:phantom", | ||
"jsdoc2md": "jsdoc-parse ./src/index.js | dmd > API.md", | ||
"zuul": "zuul --local 9966 --ui tape -- test/index.js", | ||
"zuul:server": "zuul --local 9966 --ui tape -- test/index.js", | ||
"zuul:phantom": "zuul --phantom --ui tape -- test/index.js | tap-spec", | ||
"zuul:sauce": "zuul test/index.js", | ||
"version": "chg release -y && git add -A CHANGELOG.md" | ||
@@ -48,3 +50,3 @@ }, | ||
"jsdoc-parse": "^1.1.1", | ||
"jsdom": "^3.1.2", | ||
"phantomjs": "^1.9.18", | ||
"tap-spec": "*", | ||
@@ -51,0 +53,0 @@ "tape": "*", |
const isDefined = (a) => typeof a !== 'undefined'; | ||
const isUndefined = (a) => typeof a === 'undefined'; | ||
const isObject = (a) => { return a !== null && typeof a === 'object'; }; | ||
@@ -14,2 +15,14 @@ | ||
// Gets computed styles for an element | ||
// from https://github.com/jquery/jquery/blob/master/src/css/var/getStyles.js | ||
function getComputedStyles(node) { | ||
if (useComputedStyles) { | ||
var view = node.ownerDocument.defaultView; | ||
if ( !view.opener ) view = window; | ||
return view.getComputedStyle(node,null); | ||
} else { | ||
return node.currentStyle || node.style; | ||
} | ||
} | ||
/** | ||
@@ -30,8 +43,8 @@ * Returns a collection of CSS property-value pairs | ||
if (useComputedStyles) { | ||
var computed = node.ownerDocument.defaultView.getComputedStyle(node,null); | ||
var keysArray = (styleList === true) ? computed : Object.keys(styleList); | ||
var computed = getComputedStyles(node); | ||
if (styleList === true) { | ||
var keysArray = useComputedStyles ? computed : Object.keys(computed); | ||
} else { | ||
var computed = isDefined(node.currentStyle) ? node.currentStyle : node.style; | ||
var keysArray = (styleList === true) ? Object.keys(computed) : Object.keys(styleList); | ||
var keysArray = Object.keys(styleList); | ||
} | ||
@@ -43,5 +56,5 @@ | ||
let def = styleList === true || styleList[key]; | ||
if (def === false || !isDefined(def)) continue; // copy never | ||
if (def === false || isUndefined(def)) continue; // copy never | ||
let value = useComputedStyles ? computed.getPropertyValue(key) : computed[key]; | ||
let value = /* computed.getPropertyValue(key) || */ computed[key]; // using getPropertyValue causes error in IE11 | ||
if (typeof value !== 'string' || value === '') continue; // invalid value | ||
@@ -48,0 +61,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9097
106