(tweens: SurfacedTween[], html: string)
| 444 | // trajectory (e.g. a child carries a flap while the parent carries the path), so |
| 445 | // annotate each tween with the animated ancestor elements above it in the DOM. |
| 446 | function attachComposedAncestors(tweens: SurfacedTween[], html: string): void { |
| 447 | const animated = [...new Set(tweens.filter((t) => t.method !== "set").map((t) => t.target))]; |
| 448 | if (animated.length < 2) return; // need ≥2 distinct animated elements to compose |
| 449 | const doc = new DOMParser().parseFromString(html, "text/html"); |
| 450 | for (const t of tweens) { |
| 451 | const ancestors = animatedAncestors(doc, t.target, animated); |
| 452 | if (ancestors.length) { |
| 453 | t.composedWith = ancestors.map((sel) => ({ |
| 454 | selector: sel, |
| 455 | summary: summarizeMotion(tweens, sel), |
| 456 | })); |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | const safeMatches = (el: Element, sel: string): boolean => { |
| 462 | try { |
no test coverage detected