- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我昨天卷入了一场关于 DOM 实现怪癖的讨论,并引发了一个关于 Text.splitText 和 Element.normalise 行为以及它们应该如何表现的有趣问题。
在DOM Level 1 Core , Text.splitText 定义为...
Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblings. This node then only contains all the content up to the offset point. And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point.
归一化是...
Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.
所以,如果我采用包含“Hello World”的文本节点,在 textNode 中引用,然后执行
textNode.splitText(3)
textNode 现在有内容“Hello”,和一个包含“World”的新兄弟节点
如果我那么
textNode.parent.normalize()
什么是 textNode?该规范没有明确指出 textNode 必须仍然是它之前父节点的子节点,只是更新为包含所有相邻的文本节点(然后被删除)。删除所有相邻的文本节点似乎是一种符合规范的行为,然后重新创建一个连接值的新节点,让 textNode 指向不再是树的一部分的东西。或者,我们可以用与 splitText 中相同的方式更新 textNode,因此它保留它的树位置,并获得一个新值。
行为的选择真的很不一样,我找不到关于哪个是正确的澄清,或者这是否只是规范中的疏忽(它似乎没有在级别 2 或 3 中得到澄清) .任何 DOM/XML 专家都可以给出一些启示吗?
最佳答案
早期我在 DOM 工作组工作;我确定我们意味着让 textNode 包含新的连接值,但是如果我们没有在规范中说它,一些可能em> 实现可能创建一个新节点而不是重用 textNode,尽管这需要实现者做更多的工作。
如有疑问,请进行防御性编程。
关于xml - DOM splitText 和 normalize compose 是否应该给出身份?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30049/
我正在使用 GSAP 插件 SplitText,在使用它时我注意到它改变了; 在我的元素中标记(注释掉 javascript 中的第一行以查看更改)。看这里:https://codepen.io/a
切入正题,我正在使用 Text.prototype.splitText 来帮助数据绑定(bind),但我以前从未见过它在任何地方使用过。 我想知道关于它的任何不好的部分,一些我在依赖它之前需要知道的东
我的目标是进行 XML 输入,将节点中的一些文本替换为 XML DOM 元素并生成 XML 输出。我的 XML 输入和预期输出可以找到 here, in this SO question . 这是我的
在 Internet Explorer 9 上,调用 splitText在文本节点上不会更新 childNodes它的 parent 。在 Chrome 和 Firefox 上,正如 https://
假设我们的页面中有一个段落,只有一个文本 block 。 laborum beatae est nihil, non hic ab, deserunt repellat quas. Est moles
我正在编写一个 javascript 网页,并在其中尝试发送此 Ajax 请求。 function onSubmit() {
我昨天卷入了一场关于 DOM 实现怪癖的讨论,并引发了一个关于 Text.splitText 和 Element.normalise 行为以及它们应该如何表现的有趣问题。 在DOM Level 1 C
我正在尝试使用 NiFi 使用 HDF 1.2 处理大型 CSV 文件(每个文件可能有数十亿条记录)。我已经实现了我的流程,对于小文件一切正常。 问题是,如果我尝试将文件大小增加到 100MB(1M
我是一名优秀的程序员,十分优秀!