本文整理汇总了TypeScript中wed/dloc.DLocRoot.nodeToPath方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DLocRoot.nodeToPath方法的具体用法?TypeScript DLocRoot.nodeToPath怎么用?TypeScript DLocRoot.nodeToPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wed/dloc.DLocRoot
的用法示例。
在下文中一共展示了DLocRoot.nodeToPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("is equivalent to nodeToPath on a data tree", () => {
const dataRootObj = new DLocRoot(xmlDoc);
linkTrees(xmlDoc.firstElementChild!, root.firstElementChild!);
let targetDataNode = xmlDoc.getElementsByTagName("quote")[0];
const phantomWrapTemplate = "<span class='_phantom_wrap'></span>";
$($.data(targetDataNode, "wed_mirror_node"))
.wrap(phantomWrapTemplate)
.after("<span class='_phantom'>Boo</span>Blip")
.wrap(phantomWrapTemplate);
const dataNode = targetDataNode.parentNode as Element;
// Wrap twice for good measure.
$($.data(dataNode, "wed_mirror_node"))
.wrap(phantomWrapTemplate)
.wrap(phantomWrapTemplate);
targetDataNode = xmlDoc.getElementsByTagName("quote")[1];
const targetGuiNode = $.data(targetDataNode, "wed_mirror_node");
const guiPath = rootObj.nodeToPath(targetGuiNode);
const dataPath = dataRootObj.nodeToPath(targetDataNode);
// Both paths should be equal.
assert.equal(guiPath, dataPath);
// It should also be reversible.
assert.equal(rootObj.pathToNode(guiPath), targetGuiNode);
});
示例2: it
it("returns a correct path on text node", () => {
const node = defined($root.find(".title")[0].childNodes[0]);
assert.equal(rootObj.nodeToPath(node), "0/0/0/0/0/0");
});