1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const camelize = require('./camelize');
- const hyphenate = require('./hyphenate');
- function asString(value) /*?string*/{
- return value == null ? value : String(value);
- }
- function getStyleProperty( node, name) /*?string*/{
- let computedStyle;
-
- if (window.getComputedStyle) {
-
- computedStyle = window.getComputedStyle(node, null);
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate(name)));
- }
- }
-
- if (document.defaultView && document.defaultView.getComputedStyle) {
- computedStyle = document.defaultView.getComputedStyle(node, null);
-
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate(name)));
- }
- if (name === 'display') {
- return 'none';
- }
- }
-
- if (node.currentStyle) {
- if (name === 'float') {
- return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat);
- }
- return asString(node.currentStyle[camelize(name)]);
- }
- return asString(node.style && node.style[camelize(name)]);
- }
- module.exports = getStyleProperty;
|