123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 'use strict';
- var camelize = require('./camelize');
- var hyphenate = require('./hyphenate');
- function asString(value) /*?string*/{
- return value == null ? value : String(value);
- }
- function getStyleProperty( node, name) /*?string*/{
- var computedStyle = void 0;
-
- 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;
|