本文整理汇总了TypeScript中wed/domutil.indexOf函数的典型用法代码示例。如果您正苦于以下问题:TypeScript indexOf函数的具体用法?TypeScript indexOf怎么用?TypeScript indexOf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了indexOf函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getElementNameFor
() => {
const elName = getElementNameFor(ps[7]);
const before = caretManager.makeCaret(elName, 0);
const after = caretManager.newPosition(before, "left")!;
const parent = ps[7].parentNode!;
assert.equal(after.node, parent);
assert.equal(after.offset, indexOf(parent.childNodes, ps[7]));
});
示例2: it
it("moves out of a start label", () => {
const p = ps[7];
const initial = getElementNameFor(p)!;
caretManager.setCaret(initial, 0);
caretCheck(editor, initial, 0, "initial");
const parent = p.parentNode!;
caretManager.move("left");
caretCheck(editor, parent, indexOf(parent.childNodes, p), "moved once");
});
示例3: it
it("removes nodes and merges text", () => {
const start = [p.firstChild!, 4] as domutil.Caret;
const end = [p.lastChild!, 3] as domutil.Caret;
assert.equal(p.childNodes.length, 5);
const nodes = Array.prototype.slice.call(
p.childNodes,
domutil.indexOf(p.childNodes, start[0].nextSibling!),
domutil.indexOf(p.childNodes, end[0].previousSibling!) + 1);
nodes.unshift(p.ownerDocument.createTextNode("re "));
nodes.push(p.ownerDocument.createTextNode(" af"));
const [final, cutContent] = cut(start, end);
// Check that we're doing what we think we're doing.
assert.equal(p.childNodes.length, 1);
assert.equal(p.innerHTML, "befoter");
// Check the caret position.
assert.deepEqual(final, [p.firstChild, 4]);
// Check that the nodes are those we expected.
checkNodes(cutContent, nodes);
});
示例4: it
it("typing text when caret is adjacent to text (before text)", () => {
// Text node inside title.
const initial = editor.dataRoot.querySelectorAll("body>p")[3];
const his = initial.getElementsByTagName("hi");
const hi = his[his.length - 1];
// We put the caret just after the last <hi>, which means it is just before
// the last text node.
caretManager.setCaret(initial, indexOf(initial.childNodes, hi) + 1);
const initialLength = initial.childNodes.length;
editor.type(" ");
assert.equal(initial.lastChild!.textContent, " c");
assert.equal(initial.childNodes.length, initialLength);
});
示例5: assertIsTextPhantom
() => {
const initial = editor.guiRoot.getElementsByClassName("ref")[0];
// Check that what we are expecting to be around the caret is correct.
const offset = 2;
const caretNode = initial.childNodes[offset];
assertIsTextPhantom(caretNode);
assertIsTextPhantom(caretNode.previousSibling);
caretManager.setCaret(initial, offset);
caretCheck(editor, initial, offset, "initial");
caretManager.move("left");
caretCheck(editor, initial.parentNode!,
indexOf(initial.parentNode!.childNodes, initial),
"moved once");
});