MCPcopy Index your code
hub / github.com/angular/angular / getElementStyles

Function getElementStyles

packages/core/testing/src/styling.ts:66–83  ·  view source on GitHub ↗
(element: Element)

Source from the content-addressed store, hash-verified

64 * @returns Map of style values.
65 */
66export function getElementStyles(element: Element): {[key: string]: string} {
67 const styles: {[key: string]: string} = {};
68 if (element.nodeType === Node.ELEMENT_NODE) {
69 const style = (element as HTMLElement).style;
70 // reading `style.color` is a work around for a bug in Domino. The issue is that Domino has
71 // stale value for `style.length`. It seems that reading a property from the element causes the
72 // stale value to be updated. (As of Domino v 2.1.3)
73 style.color;
74 for (let i = 0; i < style.length; i++) {
75 const key = style.item(i);
76 const value = style.getPropertyValue(key);
77 if (value !== '') {
78 styles[key] = value;
79 }
80 }
81 }
82 return styles;
83}

Callers 3

expectStyleFunction · 0.90
expectStyleFunction · 0.90
getSortedStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…