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


TypeScript domutil.siblingByClass方法代碼示例

本文整理匯總了TypeScript中wed.domutil.siblingByClass方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript domutil.siblingByClass方法的具體用法?TypeScript domutil.siblingByClass怎麽用?TypeScript domutil.siblingByClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wed.domutil的用法示例。


在下文中一共展示了domutil.siblingByClass方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: explanationDecorator

  explanationDecorator(root: Element, el: Element): void {
    let child;
    let next;
    let div; // Damn hoisting...
    // Handle explanations that are in btw:example-explained.
    if ((el.parentNode as Element).classList
        .contains("btw:example-explained")) {
      child = el.firstElementChild;
      while (child) {
        next = child.nextElementSibling;
        if (child.classList.contains("_explanation_bullet")) {
          this.guiUpdater.removeNode(child);
          break; // There's only one.
        }
        child = next;
      }

      const cit = domutil.siblingByClass(el, "btw:cit");
      // If the next btw:cit element contains Pāli text.
      if (cit !== null &&
          cit.querySelector(
            `*[${util.encodeAttrName("xml:lang")}='pi-Latn']`) !== null) {
        div = el.ownerDocument.createElement("div");
        div.className = "_phantom _decoration_text _explanation_bullet";
        div.style.position = "absolute";
        div.style.left = "-1em";
        div.textContent = WHEEL;
        this.guiUpdater.insertNodeAt(el, 0, div);
        (el as HTMLElement).style.position = "relative";
      }
      this.elementDecorator(root, el);
      return;
    }

    this.elementDecorator(root, el);
    let label;
    const parent = el.parentNode as Element;
    // Is it in a subsense?
    if (parent.classList.contains("btw:subsense")) {
      const refman = this.refmans.getSubsenseRefman(el)!;
      label = refman.idToSublabel(parent.id);
      child = el.firstElementChild;
      let start;
      while (child) {
        next = child.nextElementSibling;
        if (child.classList.contains("_explanation_number")) {
          this.guiUpdater.removeNode(child);
        }
        else if (child.classList.contains("__start_label")) {
          start = child;
        }
        child = next;
      }

      // We want to insert it after the start label.
      div = el.ownerDocument.createElement("div");
      div.className = "_phantom _decoration_text _explanation_number " +
        "_start_wrapper'";
      div.textContent = `${label}. `;
      this.guiUpdater.insertBefore(el, div,
                                     start ? start.nextSibling : el.firstChild);
    }

    this.headingDecorator.sectionHeadingDecorator(el);
  }
開發者ID:mangalam-research,項目名稱:btw,代碼行數:65,代碼來源:btw-dispatch.ts


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