refactor(RegExpWrapper): remove the facade (#10512)

This commit is contained in:
Jason Choi
2016-08-05 09:50:49 -07:00
committed by Alex Rickabaugh
parent b4613ab2d2
commit 83e2d3d1cb
31 changed files with 112 additions and 194 deletions

View File

@ -8,17 +8,18 @@
import {ListWrapper} from './facade/collection';
import {BaseException} from './facade/exceptions';
import {RegExpMatcherWrapper, RegExpWrapper, StringWrapper, isBlank, isPresent} from './facade/lang';
import {StringWrapper, isBlank, isPresent} from './facade/lang';
const _EMPTY_ATTR_VALUE = '';
const _SELECTOR_REGEXP = RegExpWrapper.create(
'(\\:not\\()|' + //":not("
'([-\\w]+)|' + // "tag"
'(?:\\.([-\\w]+))|' + // ".class"
'(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|' + // "[name]", "[name=value]" or "[name*=value]"
'(\\))|' + // ")"
'(\\s*,\\s*)'); // ","
const _SELECTOR_REGEXP = new RegExp(
'(\\:not\\()|' + //":not("
'([-\\w]+)|' + // "tag"
'(?:\\.([-\\w]+))|' + // ".class"
'(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|' + // "[name]", "[name=value]" or "[name*=value]"
'(\\))|' + // ")"
'(\\s*,\\s*)', // ","
'g');
/**
* A css selector contains an element name,
@ -41,11 +42,11 @@ export class CssSelector {
res.push(cssSel);
};
var cssSelector = new CssSelector();
var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
var match: string[];
var current = cssSelector;
var inNot = false;
while (isPresent(match = RegExpMatcherWrapper.next(matcher))) {
_SELECTOR_REGEXP.lastIndex = 0;
while (isPresent(match = _SELECTOR_REGEXP.exec(selector))) {
if (isPresent(match[1])) {
if (inNot) {
throw new BaseException('Nesting :not is not allowed in a selector');