PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
extendify / src / Agent / lib / computed-styles.js

computed-styles.js in Extendify 3.2.2, at src/Agent/lib/computed-styles.js

42 lines 1013 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // The baseline for relative requests — attributes alone make an unstyled h1 look
2 // size-less, so "larger" snaps below the theme default.
3 const ALLOWLIST = [
4 'fontSize',
5 'lineHeight',
6 'fontWeight',
7 'fontFamily',
8 'fontStyle',
9 'letterSpacing',
10 'textTransform',
11 'textDecoration',
12 'color',
13 'backgroundColor',
14 'borderRadius',
15 'borderWidth',
16 'borderStyle',
17 'borderColor',
18 'boxShadow',
19 'padding',
20 'margin',
21 'minHeight',
22 ];
23
24 // Every block computes a min-height; only a set one is a size to step from.
25 const isEmptyValue = (value, prop) =>
26 !value ||
27 value === 'normal' ||
28 value === 'none' ||
29 value === 'auto' ||
30 (prop === 'minHeight' && value === '0px');
31
32 export const readComputedStyles = (el) => {
33 if (!el?.ownerDocument?.defaultView) return null;
34 const cs = el.ownerDocument.defaultView.getComputedStyle(el);
35 const out = {};
36 for (const prop of ALLOWLIST) {
37 const value = cs[prop];
38 if (!isEmptyValue(value, prop)) out[prop] = value;
39 }
40 return Object.keys(out).length ? out : null;
41 };
42