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


TypeScript predicates.hasSpaceSeparatedAttrValue方法代碼示例

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


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

示例1: attributeSelectorToPredicate

function attributeSelectorToPredicate(selector: cssWhat.Attribute):
    dom5.Predicate {
  switch (selector.action) {
    case 'exists':
      return dom5.predicates.hasAttr(selector.name);
    case 'equals':
      return dom5.predicates.hasAttrValue(selector.name, selector.value);
    case 'start':
      return (el) => {
        const attrValue = dom5.getAttribute(el, selector.name);
        return attrValue != null && attrValue.startsWith(selector.value);
      };
    case 'end':
      return (el) => {
        const attrValue = dom5.getAttribute(el, selector.name);
        return attrValue != null && attrValue.endsWith(selector.value);
      };
    case 'element':
      return dom5.predicates.hasSpaceSeparatedAttrValue(
          selector.name, selector.value);
    case 'any':
      return (el) => {
        const attrValue = dom5.getAttribute(el, selector.name);
        return attrValue != null && attrValue.includes(selector.value);
      };
  }
  const never: never = selector.action;
  throw new Error(
      `Unexpected type of attribute matcher from CSS parser ${never}`);
}
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:30,代碼來源:util.ts

示例2: test

    test('with 2 entrypoints and shell, all deps in their places', async () => {
      const analyzer = getAnalyzer();
      const {documents} =
          await bundleMultiple([shell, entrypoint1, entrypoint2], {
            strategy: generateShellMergeStrategy(analyzer.resolveUrl(shell)!, 2)
          });
      assert.equal(documents.size, 3);
      const shellDoc = documents.get(shell)!.ast as dom5.Node;
      assert.isDefined(shellDoc);
      const entrypoint1Doc = documents.get(entrypoint1)!.ast as dom5.Node;
      assert.isDefined(entrypoint1Doc);
      const entrypoint2Doc = documents.get(entrypoint2)!.ast as dom5.Node;
      assert.isDefined(entrypoint2Doc);
      const shellDiv = dom5.predicates.hasAttrValue('id', 'shell');
      const shellImport = dom5.predicates.AND(
          dom5.predicates.hasTagName('link'),
          dom5.predicates.hasSpaceSeparatedAttrValue('rel', 'import'),
          dom5.predicates.hasAttrValue('href', 'shell.html'));
      const commonModule = domModulePredicate('common-module');
      const elOne = domModulePredicate('el-one');
      const elTwo = domModulePredicate('el-two');
      const depOne = domModulePredicate('el-dep1');
      const depTwo = domModulePredicate('el-dep2');

      // Check that all the dom modules are in their expected shards
      assertContainsAndExcludes(
          shellDoc, [shellDiv, commonModule, depOne], [elOne, elTwo, depTwo]);
      assertContainsAndExcludes(
          entrypoint1Doc,
          [elOne],
          [commonModule, elTwo, depOne, depTwo, shellImport]);
      assertContainsAndExcludes(
          entrypoint2Doc,
          [elTwo, depTwo],
          [commonModule, elOne, depOne, shellImport]);
    });
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:36,代碼來源:shards_test.ts


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