Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 488x 488x 488x 1062x 1062x 1062x 1062x 934x 488x | /**
* @internal
* Get CSS styles of a given element in name-value pair format
* @param element The element to get styles from
*/
export function getStyles(element: HTMLElement): Record<string, string> {
const result: Record<string, string> = {};
const style = element?.getAttribute('style') || '';
style.split(';').forEach(pair => {
const valueIndex = pair.indexOf(':');
const name = pair.slice(0, valueIndex);
const value = pair.slice(valueIndex + 1);
if (name && value) {
result[name.trim()] = value.trim();
}
});
return result;
}
|