(domNode, properties, projectionOptions)
| 283 | } |
| 284 | }; |
| 285 | var setProperties = function (domNode, properties, projectionOptions) { |
| 286 | if (!properties) { |
| 287 | return; |
| 288 | } |
| 289 | var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor; |
| 290 | var propNames = Object.keys(properties); |
| 291 | var propCount = propNames.length; |
| 292 | for (var i = 0; i < propCount; i++) { |
| 293 | var propName = propNames[i]; |
| 294 | /* tslint:disable:no-var-keyword: edge case */ |
| 295 | var propValue = properties[propName]; |
| 296 | /* tslint:enable:no-var-keyword */ |
| 297 | if (propName === 'className') { |
| 298 | throw new Error('Property "className" is not supported, use "class".'); |
| 299 | } else if (propName === 'class') { |
| 300 | if (domNode.className) { |
| 301 | // May happen if classes is specified before class |
| 302 | domNode.className += ' ' + propValue; |
| 303 | } else { |
| 304 | domNode.className = propValue; |
| 305 | } |
| 306 | } else if (propName === 'classes') { |
| 307 | // object with string keys and boolean values |
| 308 | var classNames = Object.keys(propValue); |
| 309 | var classNameCount = classNames.length; |
| 310 | for (var j = 0; j < classNameCount; j++) { |
| 311 | var className = classNames[j]; |
| 312 | if (propValue[className]) { |
| 313 | domNode.classList.add(className); |
| 314 | } |
| 315 | } |
| 316 | } else if (propName === 'styles') { |
| 317 | // object with string keys and string (!) values |
| 318 | var styleNames = Object.keys(propValue); |
| 319 | var styleCount = styleNames.length; |
| 320 | for (var j = 0; j < styleCount; j++) { |
| 321 | var styleName = styleNames[j]; |
| 322 | var styleValue = propValue[styleName]; |
| 323 | if (styleValue) { |
| 324 | checkStyleValue(styleValue); |
| 325 | projectionOptions.styleApplyer(domNode, styleName, styleValue); |
| 326 | } |
| 327 | } |
| 328 | } else if (propName === 'key') { |
| 329 | continue; |
| 330 | } else if (propValue === null || propValue === undefined) { |
| 331 | continue; |
| 332 | } else { |
| 333 | var type = typeof propValue; |
| 334 | if (type === 'function') { |
| 335 | if (propName.lastIndexOf('on', 0) === 0) { |
| 336 | if (eventHandlerInterceptor) { |
| 337 | propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers |
| 338 | } |
| 339 | if (propName === 'oninput') { |
| 340 | (function () { |
| 341 | // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput |
| 342 | var oldPropValue = propValue; |
no test coverage detected