MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / setValueForStyles

Function setValueForStyles

code/new-context-api/public/app.js:14447–14469  ·  view source on GitHub ↗

* Sets the value for multiple styles on a node. If a value is specified as * '' (empty string), the corresponding style property will be unset. * * @param {DOMElement} node * @param {object} styles

(node, styles, getStack)

Source from the content-addressed store, hash-verified

14445 * @param {object} styles
14446 */
14447function setValueForStyles(node, styles, getStack) {
14448 var style = node.style;
14449 for (var styleName in styles) {
14450 if (!styles.hasOwnProperty(styleName)) {
14451 continue;
14452 }
14453 var isCustomProperty = styleName.indexOf('--') === 0;
14454 {
14455 if (!isCustomProperty) {
14456 warnValidStyle$1(styleName, styles[styleName], getStack);
14457 }
14458 }
14459 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
14460 if (styleName === 'float') {
14461 styleName = 'cssFloat';
14462 }
14463 if (isCustomProperty) {
14464 style.setProperty(styleName, styleValue);
14465 } else {
14466 style[styleName] = styleValue;
14467 }
14468 }
14469}
14470
14471// For HTML, certain tags should omit their close tag. We keep a whitelist for
14472// those special-case tags.

Callers 2

setInitialDOMPropertiesFunction · 0.70
updateDOMPropertiesFunction · 0.70

Calls 1

dangerousStyleValueFunction · 0.70

Tested by

no test coverage detected