* This creates a string that is expected to be equivalent to the style * attribute generated by server-side rendering. It by-passes warnings and * security checks so it's not safe to use this value for anything other than * comparison. It is only used in DEV for SSR validation.
(styles)
| 15194 | * comparison. It is only used in DEV for SSR validation. |
| 15195 | */ |
| 15196 | function createDangerousStringForStyles(styles) { |
| 15197 | { |
| 15198 | var serialized = ''; |
| 15199 | var delimiter = ''; |
| 15200 | for (var styleName in styles) { |
| 15201 | if (!styles.hasOwnProperty(styleName)) { |
| 15202 | continue; |
| 15203 | } |
| 15204 | var styleValue = styles[styleName]; |
| 15205 | if (styleValue != null) { |
| 15206 | var isCustomProperty = styleName.indexOf('--') === 0; |
| 15207 | serialized += delimiter + hyphenateStyleName(styleName) + ':'; |
| 15208 | serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); |
| 15209 | |
| 15210 | delimiter = ';'; |
| 15211 | } |
| 15212 | } |
| 15213 | return serialized || null; |
| 15214 | } |
| 15215 | } |
| 15216 | |
| 15217 | /** |
| 15218 | * Sets the value for multiple styles on a node. If a value is specified as |
no test coverage detected