当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript dom5.getTextContent函数代码示例

本文整理汇总了TypeScript中dom5.getTextContent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getTextContent函数的具体用法?TypeScript getTextContent怎么用?TypeScript getTextContent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getTextContent函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getDomModules

 analyzer.elements.forEach(function(element){
   // Ignore Polymer.Base since it's special.
   if (element.is == "Polymer.Base") return;
   var domModules = getDomModules(analyzer, element.is);
   if (!domModules[0]) {
     return;
   }
   if (domModules.length > 1) {
     domModules.forEach(function(domModule) {
       unorderedModules.push(lintErrorFromNode(domModule, "dom-module " +
         "has a repeated value for id " + element.is + "."));
     });
     return;
   }
   var scriptContent = dom5.getTextContent(element.scriptElement);
   var scriptFinderPredicate = p.hasTextValue(scriptContent);
   var script = dom5.nodeWalk(loadedDoc, scriptFinderPredicate);
   var otherDomModule = dom5.nodeWalkPrior(script, domModuleForId(element.is));
   if (!otherDomModule) {
     var originalDomModule = domModules[0];
     unorderedModules.push(lintErrorFromNode(originalDomModule, "dom-module " +
       "for " + element.is +
       " should be a parent of it or earlier in the document."));
   }
 });
开发者ID:PolymerLabs,项目名称:polylint,代码行数:25,代码来源:linters.ts

示例2: offsetSourceMap

  inlineScripts.forEach((script) => {
    let content = dom5.getTextContent(script);

    const sourceMapUrlParts = content.match(sourceMappingUrlExpr);
    if (!sourceMapUrlParts) {
      return;
    }
    const sourceMapContentParts =
        sourceMapUrlParts[1].match(inlineSourceMapExpr);
    if (!sourceMapContentParts) {
      return;
    }

    const sourceRange = reparsedDoc.sourceRangeForStartTag(script)!;
    const sourceMap = base64StringToRawSourceMap(sourceMapContentParts[2]);

    const updatedMap = offsetSourceMap(
        sourceMap, sourceRange.end.line, sourceRange.end.column);

    const base64Map = rawSourceMapToBase64String(updatedMap);
    content = content.replace(
        sourceMappingUrlExpr, `${inlineSourcemapPrefix}${base64Map}\n`);

    dom5.setTextContent(script, content);
  });
开发者ID:MehdiRaash,项目名称:tools,代码行数:25,代码来源:source-map.ts

示例3: canDomModuleBeInlined

export function canDomModuleBeInlined(domModule: parse5.ASTNode) {
  if (domModule.attrs.some((a) => a.name !== 'id')) {
    return false;  // attributes other than 'id' on dom-module
  }
  let templateTagsSeen = 0;
  for (const node of domModule.childNodes || []) {
    if (node.tagName === 'template') {
      if (node.attrs.length > 0) {
        return false;  // attributes on template
      }
      templateTagsSeen++;
    } else if (node.tagName === 'script') {
      // this is fine, scripts are handled elsewhere
    } else if (
        dom5.isTextNode(node) && dom5.getTextContent(node).trim() === '') {
      // empty text nodes are fine
    } else {
      return false;  // anything else, we can't convert it
    }
  }
  if (templateTagsSeen > 1) {
    return false;  // more than one template tag, can't convert
  }

  return true;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例4: ScannedScriptTagImport

    const myVisitor: HtmlVisitor = (node) => {
      if (isJsScriptNode(node)) {
        const src =
            dom5.getAttribute(node, 'src') as FileRelativeUrl | undefined;
        if (src) {
          features.push(new ScannedScriptTagImport(
              'html-script',
              src,
              document.sourceRangeForNode(node)!,
              document.sourceRangeForAttributeValue(node, 'src')!,
              node,
              false));
        } else {
          const locationOffset = getLocationOffsetOfStartOfTextContent(node);
          const attachedCommentText = getAttachedCommentText(node) || '';
          const contents = dom5.getTextContent(node);

          features.push(new ScannedInlineDocument(
              'js',
              contents,
              locationOffset,
              attachedCommentText,
              document.sourceRangeForNode(node)!,
              node));
        }
      }
    };
开发者ID:asdfg9822,项目名称:polymer-analyzer,代码行数:27,代码来源:html-script-scanner.ts

示例5: test

 test('Escape inline <script>', async () => {
   const {ast: doc} = await bundle('xss.html', options);
   const script = dom5.query(doc, matchers.inlineNonModuleScript)!;
   assert.include(
       dom5.getTextContent(script),
       'var b = 0<\\/script><script>alert(\'XSS\'); //2;',
       'Inline <script> should be escaped');
 });
开发者ID:Polymer,项目名称:tools,代码行数:8,代码来源:bundler_test.ts


注:本文中的dom5.getTextContent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。