MCPcopy Create free account
hub / github.com/angular/angular / classKeyValueArraySet

Function classKeyValueArraySet

packages/core/src/render3/instructions/styling.ts:775–785  ·  view source on GitHub ↗
(keyValueArray: KeyValueArray<any>, key: unknown, value: any)

Source from the content-addressed store, hash-verified

773 * @param value The value to set.
774 */
775export function classKeyValueArraySet(keyValueArray: KeyValueArray<any>, key: unknown, value: any) {
776 // We use `classList.add` to eventually add the CSS classes to the DOM node. Any value passed into
777 // `add` is stringified and added to the `class` attribute, e.g. even null, undefined or numbers
778 // will be added. Stringify the key here so that our internal data structure matches the value in
779 // the DOM. The only exceptions are empty strings and strings that contain spaces for which
780 // the browser throws an error. We ignore such values, because the error is somewhat cryptic.
781 const stringKey = String(key);
782 if (stringKey !== '' && !stringKey.includes(' ')) {
783 keyValueArraySet(keyValueArray, stringKey, value);
784 }
785}
786
787/**
788 * Update map based styling.

Callers

nothing calls this directly

Calls 1

keyValueArraySetFunction · 0.90

Tested by

no test coverage detected