(domNode, previousProperties, properties, projectionOptions)
| 362 | } |
| 363 | }; |
| 364 | var updateProperties = function (domNode, previousProperties, properties, projectionOptions) { |
| 365 | if (!properties) { |
| 366 | return; |
| 367 | } |
| 368 | var propertiesUpdated = false; |
| 369 | var propNames = Object.keys(properties); |
| 370 | var propCount = propNames.length; |
| 371 | for (var i = 0; i < propCount; i++) { |
| 372 | var propName = propNames[i]; |
| 373 | // assuming that properties will be nullified instead of missing is by design |
| 374 | var propValue = properties[propName]; |
| 375 | var previousValue = previousProperties[propName]; |
| 376 | if (propName === 'class') { |
| 377 | if (previousValue !== propValue) { |
| 378 | throw new Error('"class" property may not be updated. Use the "classes" property for conditional css classes.'); |
| 379 | } |
| 380 | } else if (propName === 'classes') { |
| 381 | var classList = domNode.classList; |
| 382 | var classNames = Object.keys(propValue); |
| 383 | var classNameCount = classNames.length; |
| 384 | for (var j = 0; j < classNameCount; j++) { |
| 385 | var className = classNames[j]; |
| 386 | var on = !!propValue[className]; |
| 387 | var previousOn = !!previousValue[className]; |
| 388 | if (on === previousOn) { |
| 389 | continue; |
| 390 | } |
| 391 | propertiesUpdated = true; |
| 392 | if (on) { |
| 393 | classList.add(className); |
| 394 | } else { |
| 395 | classList.remove(className); |
| 396 | } |
| 397 | } |
| 398 | } else if (propName === 'styles') { |
| 399 | var styleNames = Object.keys(propValue); |
| 400 | var styleCount = styleNames.length; |
| 401 | for (var j = 0; j < styleCount; j++) { |
| 402 | var styleName = styleNames[j]; |
| 403 | var newStyleValue = propValue[styleName]; |
| 404 | var oldStyleValue = previousValue[styleName]; |
| 405 | if (newStyleValue === oldStyleValue) { |
| 406 | continue; |
| 407 | } |
| 408 | propertiesUpdated = true; |
| 409 | if (newStyleValue) { |
| 410 | checkStyleValue(newStyleValue); |
| 411 | projectionOptions.styleApplyer(domNode, styleName, newStyleValue); |
| 412 | } else { |
| 413 | projectionOptions.styleApplyer(domNode, styleName, ''); |
| 414 | } |
| 415 | } |
| 416 | } else { |
| 417 | if (!propValue && typeof previousValue === 'string') { |
| 418 | propValue = ''; |
| 419 | } |
| 420 | if (propName === 'value') { |
| 421 | if (domNode[propName] !== propValue && domNode['oninput-value'] !== propValue) { |
no test coverage detected