33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.isStyleSupport = isStyleSupport;
|
|
var _canUseDom = _interopRequireDefault(require("./canUseDom"));
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
const isStyleNameSupport = styleName => {
|
|
if ((0, _canUseDom.default)() && window.document.documentElement) {
|
|
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
|
|
const {
|
|
documentElement
|
|
} = window.document;
|
|
return styleNameList.some(name => name in documentElement.style);
|
|
}
|
|
return false;
|
|
};
|
|
const isStyleValueSupport = (styleName, value) => {
|
|
if (!isStyleNameSupport(styleName)) {
|
|
return false;
|
|
}
|
|
const ele = document.createElement('div');
|
|
const origin = ele.style[styleName];
|
|
ele.style[styleName] = value;
|
|
return ele.style[styleName] !== origin;
|
|
};
|
|
function isStyleSupport(styleName, styleValue) {
|
|
if (!Array.isArray(styleName) && styleValue !== undefined) {
|
|
return isStyleValueSupport(styleName, styleValue);
|
|
}
|
|
return isStyleNameSupport(styleName);
|
|
} |