(element: Element)
| 64 | * @returns Map of style values. |
| 65 | */ |
| 66 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…