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


TypeScript dom5.remove函數代碼示例

本文整理匯總了TypeScript中dom5.remove函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript remove函數的具體用法?TypeScript remove怎麽用?TypeScript remove使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: removeElementAndNewline

export function removeElementAndNewline(node: ASTNode, replacement?: ASTNode) {
  const siblings = Array.from(node.parentNode!.childNodes!);
  let nextIdx = siblings.indexOf(node) + 1;
  let next = siblings[nextIdx];
  while (next && isBlankTextNode(next)) {
    dom5.remove(next);
    next = siblings[++nextIdx];
  }
  if (replacement) {
    dom5.replace(node, replacement);
  } else {
    dom5.remove(node);
  }
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:14,代碼來源:parse5-utils.ts

示例2: _removeEmptyHiddenDivs

 /**
  * Removes all empty hidden container divs from the AST.
  */
 private _removeEmptyHiddenDivs(ast: ASTNode) {
   for (const div of dom5.queryAll(ast, matchers.hiddenDiv)) {
     if (serialize(div).trim() === '') {
       dom5.remove(div);
     }
   }
 }
開發者ID:Polymer,項目名稱:vulcanize,代碼行數:10,代碼來源:html-bundler.ts

示例3: _addSharedImportsToShell

  _addSharedImportsToShell(bundles: Map<string, string[]>): string {
    console.assert(this.shell != null);
    let shellDeps = bundles.get(this.shell)
        .map((d) => path.relative(path.dirname(this.shell), d));

    let file = this.analyzer.files.get(this.shell);
    console.assert(file != null);
    let contents = file.contents.toString();
    let doc = dom5.parse(contents);
    let imports = dom5.queryAll(doc, dom5.predicates.AND(
      dom5.predicates.hasTagName('link'),
      dom5.predicates.hasAttrValue('rel', 'import')
    ));

    // Remove all imports that are in the shared deps list so that we prefer
    // the ordering or shared deps. Any imports left should be independent of
    // ordering of shared deps.
    let shellDepsSet = new Set(shellDeps);
    for (let _import of imports) {
      if (shellDepsSet.has(dom5.getAttribute(_import, 'href'))) {
        dom5.remove(_import);
      }
    }

    // Append all shared imports to the end of <head>
    let head = dom5.query(doc, dom5.predicates.hasTagName('head'));
    for (let dep of shellDeps) {
      let newImport = dom5.constructors.element('link');
      dom5.setAttribute(newImport, 'rel', 'import');
      dom5.setAttribute(newImport, 'href', dep);
      dom5.append(head, newImport);
    }
    let newContents = dom5.serialize(doc);
    return newContents;
  }
開發者ID:LostInBrittany,項目名稱:polymer-cli,代碼行數:35,代碼來源:bundle.ts

示例4: _addSharedImportsToShell

  _addSharedImportsToShell(bundles: Map<string, string[]>): string {
    console.assert(this.shell != null);
    let shellUrl = urlFromPath(this.root, this.shell);
    let shellUrlDir = posixPath.dirname(shellUrl);
    let shellDeps = bundles.get(shellUrl)
      .map((d) => posixPath.relative(shellUrlDir, d));
    logger.debug('found shell dependencies', {
      shellUrl: shellUrl,
      shellUrlDir: shellUrlDir,
      shellDeps: shellDeps,
    });

    let file = this.analyzer.getFile(this.shell);
    console.assert(file != null);
    let contents = file.contents.toString();
    let doc = dom5.parse(contents);
    let imports = dom5.queryAll(doc, dom5.predicates.AND(
      dom5.predicates.hasTagName('link'),
      dom5.predicates.hasAttrValue('rel', 'import')
    ));
    logger.debug('found html import elements', {
      imports: imports.map((el) => dom5.getAttribute(el, 'href')),
    });

    // Remove all imports that are in the shared deps list so that we prefer
    // the ordering or shared deps. Any imports left should be independent of
    // ordering of shared deps.
    let shellDepsSet = new Set(shellDeps);
    for (let _import of imports) {
      let importHref = dom5.getAttribute(_import, 'href');
      if (shellDepsSet.has(importHref)) {
        logger.debug(`removing duplicate import element "${importHref}"...`);
        dom5.remove(_import);
      }
    }

    // Append all shared imports to the end of <head>
    let head = dom5.query(doc, dom5.predicates.hasTagName('head'));
    for (let dep of shellDeps) {
      let newImport = dom5.constructors.element('link');
      dom5.setAttribute(newImport, 'rel', 'import');
      dom5.setAttribute(newImport, 'href', dep);
      dom5.append(head, newImport);
    }
    let newContents = dom5.serialize(doc);
    return newContents;
  }
開發者ID:augint,項目名稱:polymer-cli,代碼行數:47,代碼來源:bundle.ts

示例5: insertAfter

export function insertAfter(target: ASTNode, node: ASTNode) {
  dom5.remove(node);
  const index = target.parentNode!.childNodes!.indexOf(target);
  target.parentNode!.childNodes!.splice(index + 1, 0, node);
  node.parentNode = target.parentNode!;
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:6,代碼來源:parse5-utils.ts


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