我希望在页面上的多个位置呈现“相同”的
HTML元素.
此元素是脚本/动画的,各种渲染需要保持同步.
我考虑过的解决方案包括:
>将元素的副本放在多个位置并更新所有元素.这就是我想要避免的.
>将元素的副本放在多个位置.更新其中一个副本,并使用突变事件捕获这些更改并将其重放到其他副本.好像很多工作.
>使用shadow DOM.我对这个替代方案寄予厚望,最初似乎是可能的,使用“插入点”,允许这里的DOM子树虚拟放置在那里的DOM子树中.
One case that deserves special consideration is the situation when an
insertion point is a child node of another shadow host…The effect of a node being
distributed into more than one insertion point is called reprojection.
但是之后…
Despite being distributed to more than one insertion point during
reprojection,a node is still only rendered once,because of the
constraints under which the reprojection occurs: since the insertion
points are only subject to reprojection when they are children of a
shadow host,they are never rendered. Instead the shadow tree is
rendered in their place.
是否有可能影子DOM可能做我想要的并且值得测试,或者是否有其他推荐的方法?