知识卡片
插入垫片还要保留失败契约
Insert封装用四个位置名称映射到before/after/atStart/atEnd,辅助fragment用div解析并转移子节点。它继承了通用div解析的上下文限制;switch对未知位置没有报错分支,不能仅因已知四值可用就声称完整复刻原生API。元素外侧插入还需要合适父节点,HTML输入同样要考虑信任边界,静默不插入不应被误判为成功。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
switch(pos.toLowerCase()){ case"beforebegin":return Insert.before(this,html); case"afterend":return Insert.after(this,html); case"afterbegin":return Insert.atStart(this,html); case
参考来源
- 位置:《JavaScript权威指南(原书第6版)》第15章《15.6.4 使用DocumentFragment》(spine34;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0027.html;u337-ch15-037)。
- 结论依据:原文在“switch(pos.toLowerCase())”附近的定义、例子或代码支撑本卡核心说明:Insert封装用四个位置名称映射到before/after/atStart/atEnd,辅助fragment用div解析并转移子节点。边界按已读前提解释;示例未执行。
- 原始内容:switch(pos.toLowerCase()){ case"beforebegin":return Insert.before(this,html); case"afterend":return Insert.after(this,html); case"afterbegin":return Insert.atStart(this,html); case