当前位置: 首页>>代码示例>>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;未经允许,请勿转载。