amis-rpc-design/node_modules/rc-util/lib/Dom/styleChecker.js
2023-10-07 19:42:30 +08:00

33 lines
1.2 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isStyleSupport = isStyleSupport;
var _canUseDom = _interopRequireDefault(require("./canUseDom"));
var isStyleNameSupport = function isStyleNameSupport(styleName) {
if ((0, _canUseDom.default)() && window.document.documentElement) {
var styleNameList = Array.isArray(styleName) ? styleName : [styleName];
var documentElement = window.document.documentElement;
return styleNameList.some(function (name) {
return name in documentElement.style;
});
}
return false;
};
var isStyleValueSupport = function isStyleValueSupport(styleName, value) {
if (!isStyleNameSupport(styleName)) {
return false;
}
var ele = document.createElement('div');
var 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);
}