forgeplus-react/node_modules/dom-lib/es/style/addStyle.js

28 lines
728 B
JavaScript

import hyphenateStyleName from './hyphenateStyleName';
import removeStyle from './removeStyle';
export default (function (node, property, value) {
var css = '';
var props = property;
if (typeof property === 'string') {
if (value === undefined) {
throw new Error('value is undefined');
}
(props = {})[property] = value;
}
if (typeof props === 'object') {
for (var key in props) {
if (Object.prototype.hasOwnProperty.call(props, key)) {
if (!props[key] && props[key] !== 0) {
removeStyle(node, hyphenateStyleName(key));
} else {
css += hyphenateStyleName(key) + ":" + props[key] + ";";
}
}
}
}
node.style.cssText += ";" + css;
});