本文整理匯總了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");
});