(doc: Document)
| 174 | // and mutations agree on which element is the composition root. |
| 175 | // fallow-ignore-next-line complexity |
| 176 | function extractDimensions(doc: Document): { width: number | null; height: number | null } { |
| 177 | const stage = findRoot(doc); |
| 178 | if (!stage) return { width: null, height: null }; |
| 179 | // data-width/data-height are the runtime's forced override — prefer them. |
| 180 | const wAttr = stage.getAttribute("data-width"); |
| 181 | const hAttr = stage.getAttribute("data-height"); |
| 182 | const style = (stage as HTMLElement).getAttribute?.("style") ?? ""; |
| 183 | const wm = /width:\s*(\d+)px/.exec(style); |
| 184 | const hm = /height:\s*(\d+)px/.exec(style); |
| 185 | return { |
| 186 | width: wAttr !== null ? parseInt(wAttr, 10) : wm ? parseInt(wm[1] ?? "", 10) : null, |
| 187 | height: hAttr !== null ? parseInt(hAttr, 10) : hm ? parseInt(hm[1] ?? "", 10) : null, |
| 188 | }; |
| 189 | } |
| 190 | |
| 191 | function extractDuration(doc: Document): number | null { |
| 192 | const root = findRoot(doc) ?? doc.body; |
no test coverage detected