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


TypeScript parse5.treeAdapters.default類代碼示例

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


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

示例1: _moveDomModuleStyleIntoTemplate

  /**
   * Old Polymer supported `<style>` tag in `<dom-module>` but outside of
   * `<template>`.  This is also where the deprecated Polymer CSS import tag
   * `<link rel="import" type="css">` would generate inline `<style>`.
   * Migrates these `<style>` tags into available `<template>` of the
   * `<dom-module>`.  Will create a `<template>` container if not present.
   *
   * TODO(usergenic): Why is this in bundler... shouldn't this be some kind of
   * polyup or pre-bundle operation?
   */
  private _moveDomModuleStyleIntoTemplate(style: ASTNode, refStyle?: ASTNode) {
    const domModule =
        dom5.nodeWalkAncestors(style, dom5.predicates.hasTagName('dom-module'));
    if (!domModule) {
      return;
    }
    let template = dom5.query(domModule, matchers.template);
    if (!template) {
      template = dom5.constructors.element('template')!;
      treeAdapters.default.setTemplateContent(
          template, dom5.constructors.fragment());
      prepend(domModule, template);
    }
    removeElementAndNewline(style);

    // Ignore the refStyle object if it is contained within a different
    // dom-module.
    if (refStyle &&
        !dom5.query(
            domModule, (n) => n === refStyle, dom5.childNodesIncludeTemplate)) {
      refStyle = undefined;
    }

    // keep ordering if previding with a reference style
    if (!refStyle) {
      prepend(treeAdapters.default.getTemplateContent(template), style);
    } else {
      insertAfter(refStyle, style);
    }
  }
開發者ID:Polymer,項目名稱:vulcanize,代碼行數:40,代碼來源:html-bundler.ts

示例2: ScannedElementReference

    const visitor = (node: ASTNode) => {
      if (node.tagName && this.matches(node)) {
        const element = new ScannedElementReference(
            node.tagName, document.sourceRangeForNode(node)!, node);

        if (node.attrs) {
          for (const attr of node.attrs) {
            element.attributes.set(attr.name, {
              name: attr.name,
              value: attr.value,
              sourceRange: document.sourceRangeForAttribute(node, attr.name)!,
              nameSourceRange:
                  document.sourceRangeForAttributeName(node, attr.name)!,
              valueSourceRange:
                  document.sourceRangeForAttributeValue(node, attr.name)
            });
          }
        }

        elements.push(element);
      }

      // Descend into templates.
      if (node.tagName === 'template') {
        const content = treeAdapters.default.getTemplateContent(node);
        if (content) {
          dom5.nodeWalk(content, (n) => {
            visitor(n);
            return false;
          });
        }
      }
    };
開發者ID:asdfg9822,項目名稱:polymer-analyzer,代碼行數:33,代碼來源:html-element-reference-scanner.ts

示例3: ScannedElementReference

    const visitor = (node: ASTNode) => {
      if (node.tagName && this.matches(node)) {
        const element = new ScannedElementReference(
            node.tagName,
            document.sourceRangeForNode(node)!,
            {language: 'html', containingDocument: document, node});

        if (node.attrs) {
          for (const attr of node.attrs) {
            element.attributes.set(attr.name, {
              name: attr.name,
              value: attr.value,
              sourceRange: document.sourceRangeForAttribute(node, attr.name)!,
              nameSourceRange:
                  document.sourceRangeForAttributeName(node, attr.name)!,
              valueSourceRange:
                  document.sourceRangeForAttributeValue(node, attr.name)
            });
          }
        }

        elements.push(element);
      }

      // Descend into templates.
      if (node.tagName === 'template') {
        const content = treeAdapters.default.getTemplateContent(node);
        if (content) {
          for (const n of dom5.depthFirst(content)) {
            visitor(n);
          }
        }
      }
    };
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:34,代碼來源:html-element-reference-scanner.ts

示例4: childNodesIncludeTemplate

export const childNodesIncludeTemplate = function childNodesIncludeTemplate(
    node: Node) {
  if (node.nodeName === 'template') {
    return treeAdapters.default.getTemplateContent(node).childNodes;
  }

  return node.childNodes;
};
開發者ID:Polymer,項目名稱:tools,代碼行數:8,代碼來源:util.ts

示例5: async

 const visitor = async (node: ASTNode) => {
   if (isStyleNode(node)) {
     const tagName = node.nodeName;
     if (tagName === 'link') {
       const href = dom5.getAttribute(node, 'href')! as FileRelativeUrl;
       features.push(new ScannedImport(
           'html-style',
           href,
           document.sourceRangeForNode(node)!,
           document.sourceRangeForAttributeValue(node, 'href')!,
           {language: 'html', node, containingDocument: document},
           true));
     } else {
       const contents = dom5.getTextContent(node);
       const locationOffset =
           getLocationOffsetOfStartOfTextContent(node, document);
       const commentText = getAttachedCommentText(node) || '';
       features.push(new ScannedInlineDocument(
           'css',
           contents,
           locationOffset,
           commentText,
           document.sourceRangeForNode(node)!,
           {language: 'html', node, containingDocument: document}));
     }
   }
   // Descend into templates.
   if (node.tagName === 'template') {
     const content = treeAdapters.default.getTemplateContent(node);
     if (content) {
       for (const n of dom5.depthFirst(content)) {
         visitor(n);
       }
     }
   }
 };
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:36,代碼來源:html-style-scanner.ts


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