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


TypeScript CssSelector.parse方法代碼示例

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


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

示例1: it

    it('should select by element name, class name and attribute name with value', () => {
      matcher.addSelectables(s1 = CssSelector.parse('someTag.someClass[someAttr=someValue]'), 1);

      expect(matcher.match(
                 CssSelector.parse('someOtherTag.someOtherClass[someOtherAttr]')[0],
                 selectableCollector))
          .toEqual(false);
      expect(matched).toEqual([]);

      expect(
          matcher.match(
              CssSelector.parse('someTag.someOtherClass[someOtherAttr]')[0], selectableCollector))
          .toEqual(false);
      expect(matched).toEqual([]);

      expect(matcher.match(
                 CssSelector.parse('someTag.someClass[someOtherAttr]')[0], selectableCollector))
          .toEqual(false);
      expect(matched).toEqual([]);

      expect(
          matcher.match(CssSelector.parse('someTag.someClass[someAttr]')[0], selectableCollector))
          .toEqual(false);
      expect(matched).toEqual([]);

      expect(
          matcher.match(
              CssSelector.parse('someTag.someClass[someAttr=someValue]')[0], selectableCollector))
          .toEqual(true);
      expect(matched).toEqual([s1[0], 1]);
    });
開發者ID:4vanger,項目名稱:angular,代碼行數:31,代碼來源:selector_spec.ts

示例2: it

    it('should detect :not', () => {
      var cssSelector = CssSelector.parse('sometag:not([attrname=attrvalue].someclass)')[0];
      expect(cssSelector.element).toEqual('sometag');
      expect(cssSelector.attrs.length).toEqual(0);
      expect(cssSelector.classNames.length).toEqual(0);

      var notSelector = cssSelector.notSelectors[0];
      expect(notSelector.element).toEqual(null);
      expect(notSelector.attrs).toEqual(['attrname', 'attrvalue']);
      expect(notSelector.classNames).toEqual(['someclass']);

      expect(cssSelector.toString()).toEqual('sometag:not(.someclass[attrname=attrvalue])');
    });
開發者ID:jessepinho,項目名稱:angular,代碼行數:13,代碼來源:selector_spec.ts

示例3: it

    it('should select by element name case sensitive', () => {
      matcher.addSelectables(s1 = CssSelector.parse('someTag'), 1);

      expect(matcher.match(getSelectorFor({tag: 'SOMEOTHERTAG'}), selectableCollector))
          .toEqual(false);
      expect(matched).toEqual([]);

      expect(matcher.match(getSelectorFor({tag: 'SOMETAG'}), selectableCollector)).toEqual(false);
      expect(matched).toEqual([]);

      expect(matcher.match(getSelectorFor({tag: 'someTag'}), selectableCollector)).toEqual(true);
      expect(matched).toEqual([s1[0], 1]);
    });
開發者ID:JSMike,項目名稱:angular,代碼行數:13,代碼來源:selector_spec.ts

示例4: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var count = getIntParameter('selectors');

  var fixedMatcher;
  var fixedSelectorStrings = [];
  var fixedSelectors = [];
  for (var i = 0; i < count; i++) {
    fixedSelectorStrings.push(randomSelector());
  }
  for (var i = 0; i < count; i++) {
    fixedSelectors.push(CssSelector.parse(fixedSelectorStrings[i]));
  }
  fixedMatcher = new SelectorMatcher();
  for (var i = 0; i < count; i++) {
    fixedMatcher.addSelectables(fixedSelectors[i], i);
  }

  function parse() {
    var result = [];
    for (var i = 0; i < count; i++) {
      result.push(CssSelector.parse(fixedSelectorStrings[i]));
    }
    return result;
  }

  function addSelectable() {
    var matcher = new SelectorMatcher();
    for (var i = 0; i < count; i++) {
      matcher.addSelectables(fixedSelectors[i], i);
    }
    return matcher;
  }

  function match() {
    var matchCount = 0;
    for (var i = 0; i < count; i++) {
      fixedMatcher.match(fixedSelectors[i][0], (selector, selected) => { matchCount += selected; });
    }
    return matchCount;
  }

  bindAction('#parse', parse);
  bindAction('#addSelectable', addSelectable);
  bindAction('#match', match);
}
開發者ID:0xJoKe,項目名稱:angular,代碼行數:46,代碼來源:selector_benchmark.ts

示例5: expect

       () => {
         let selector = CssSelector.parse('Blink.neon.hotpink[Sweet][Dismissable=false]')[0];
         let template = selector.getMatchingElementTemplate();

         expect(template).toEqual('<Blink class="neon hotpink" Sweet Dismissable="false"></Blink>');
       });
開發者ID:jessepinho,項目名稱:angular,代碼行數:6,代碼來源:selector_spec.ts


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