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


TypeScript predicates.OR方法代碼示例

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


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

示例1: simpleSelectorToPredicate

function simpleSelectorToPredicate(
    selector: cssWhat.Simple, isPolymerTemplate: boolean) {
  switch (selector.type) {
    case 'adjacent':
    case 'child':
    case 'descendant':
    case 'parent':
    case 'sibling':
    case 'pseudo':
      throw new Error(`Unsupported CSS operator: ${selector.type}`);
    case 'attribute':
      if (isPolymerTemplate) {
        return dom5.predicates.OR(
            attributeSelectorToPredicate(selector),
            attributeSelectorToPredicate(
                {...selector, name: selector.name + '$'}));
      }
      return attributeSelectorToPredicate(selector);
    case 'tag':
      return dom5.predicates.hasTagName(selector.name);
    case 'universal':
      return () => true;
  }
  const never: never = selector;
  throw new Error(`Unexpected node type from css parser: ${never}`);
}
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:26,代碼來源:util.ts

示例2: test

 test('bundle documents should not have tags added to them', async () => {
   const {ast} = await bundle('imports/simple-import.html');
   assert.isNull(dom5.query(
       ast,
       dom5.predicates.OR(
           dom5.predicates.hasTagName('html'),
           dom5.predicates.hasTagName('head'),
           dom5.predicates.hasTagName('body'))));
 });
開發者ID:Polymer,項目名稱:tools,代碼行數:9,代碼來源:bundler_test.ts

示例3: elementSelectorToPredicate

export function elementSelectorToPredicate(
    simpleSelector: string,
    isPolymerTemplate: boolean = false): dom5.Predicate {
  const parsed = cssWhat(simpleSelector);
  // The output of cssWhat is two levels of arrays. The outer level are any
  // selectors joined with a comma, so it matches if any of the inner selectors
  // match. The inner array are simple selectors like `.foo` and `#bar` which
  // must all match.
  return dom5.predicates.OR(...parsed.map((simpleSelectors) => {
    return dom5.predicates.AND(...simpleSelectors.map(
        (selector) => simpleSelectorToPredicate(selector, isPolymerTemplate)));
  }));
}
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:13,代碼來源:util.ts

示例4:

// jshint node: true
'use strict';

import constants from './constants';
import {predicates} from 'dom5';
import * as parse5 from 'parse5';

export interface Matcher { (node: parse5.ASTNode): boolean; }

// TODO(aomarks) Look at what's using this matcher. A number of code paths
// should probably not be excluding type=module scripts.
export const nonModuleScript: Matcher = predicates.AND(
    predicates.hasTagName('script'),
    predicates.OR(
        predicates.NOT(predicates.hasAttr('type')),
        predicates.hasAttrValue('type', 'text/javascript'),
        predicates.hasAttrValue('type', 'application/javascript')));

export const moduleScript: Matcher = predicates.AND(
    predicates.hasTagName('script'), predicates.hasAttrValue('type', 'module'));

export const externalStyle: Matcher = predicates.AND(
    predicates.hasTagName('link'),
    predicates.hasAttrValue('rel', 'stylesheet'));
// polymer specific external stylesheet
export const polymerExternalStyle: Matcher = predicates.AND(
    predicates.hasTagName('link'),
    predicates.hasAttrValue('rel', 'import'),
    predicates.hasAttrValue('type', 'css'));

export const styleMatcher: Matcher = predicates.AND(
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:31,代碼來源:matchers.ts


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