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

Function classKeyValueArraySet

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

keyValueArraySetFunction · 0.90

Tested by

no test coverage detected