All files / react-native-web/src/modules/setValueForStyles index.js

72.73% Statements 8/11
50% Branches 3/6
100% Functions 1/1
72.73% Lines 8/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                                            9x 9x 27x     27x 27x 27x     27x     27x            
/* eslint-disable */
 
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * From React 16.3.0
 * @noflow
 */
 
import dangerousStyleValue from './dangerousStyleValue';
 
/**
 * 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
 */
function setValueForStyles(node, styles) {
  const style = node.style;
  for (let styleName in styles) {
    Iif (!styles.hasOwnProperty(styleName)) {
      continue;
    }
    const isCustomProperty = styleName.indexOf('--') === 0;
    const styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
    Iif (styleName === 'float') {
      styleName = 'cssFloat';
    }
    Iif (isCustomProperty) {
      style.setProperty(styleName, styleValue);
    } else {
      style[styleName] = styleValue;
    }
  }
}
 
export default setValueForStyles;