當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript domutil.indexOf函數代碼示例

本文整理匯總了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]));
 });
開發者ID:lddubeau,項目名稱:wed,代碼行數:8,代碼來源:wed-caret-test.ts

示例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");
    });
開發者ID:lddubeau,項目名稱:wed,代碼行數:10,代碼來源:wed-caret-test.ts

示例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);
    });
開發者ID:lddubeau,項目名稱:wed,代碼行數:24,代碼來源:domutil-test.ts

示例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);
  });
開發者ID:lddubeau,項目名稱:wed,代碼行數:16,代碼來源:wed-typing-test.ts

示例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");
       });
開發者ID:lddubeau,項目名稱:wed,代碼行數:17,代碼來源:wed-caret-test.ts


注:本文中的wed/domutil.indexOf函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。