2015-02-05 16:08:05 -05:00
|
|
|
import {List, Map, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
2015-05-18 14:57:20 -04:00
|
|
|
import {
|
|
|
|
isPresent,
|
|
|
|
isBlank,
|
|
|
|
RegExpWrapper,
|
|
|
|
RegExpMatcherWrapper,
|
|
|
|
StringWrapper,
|
|
|
|
BaseException
|
|
|
|
} from 'angular2/src/facade/lang';
|
2014-10-02 23:39:27 -04:00
|
|
|
|
2014-10-28 17:46:55 -04:00
|
|
|
const _EMPTY_ATTR_VALUE = '';
|
|
|
|
|
2014-11-11 20:33:47 -05:00
|
|
|
// TODO: Can't use `const` here as
|
|
|
|
// in Dart this is not transpiled into `final` yet...
|
2015-05-18 14:57:20 -04:00
|
|
|
var _SELECTOR_REGEXP = RegExpWrapper.create(
|
|
|
|
'(\\:not\\()|' + //":not("
|
|
|
|
'([-\\w]+)|' + // "tag"
|
|
|
|
'(?:\\.([-\\w]+))|' + // ".class"
|
|
|
|
'(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|' + // "[name]", "[name=value]" or "[name*=value]"
|
|
|
|
'(?:\\))|' + // ")"
|
|
|
|
'(\\s*,\\s*)'); // ","
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2014-11-11 20:33:47 -05:00
|
|
|
/**
|
|
|
|
* A css selector contains an element name,
|
|
|
|
* css classes and attribute/value pairs with the purpose
|
|
|
|
* of selecting subsets out of them.
|
|
|
|
*/
|
|
|
|
export class CssSelector {
|
2015-05-18 14:57:20 -04:00
|
|
|
element: string;
|
|
|
|
classNames: List<string>;
|
|
|
|
attrs: List<string>;
|
2015-03-12 04:44:49 -04:00
|
|
|
notSelector: CssSelector;
|
2015-05-18 14:57:20 -04:00
|
|
|
static parse(selector: string): List<CssSelector> {
|
2015-03-19 12:01:42 -04:00
|
|
|
var results = ListWrapper.create();
|
|
|
|
var _addResult = (res, cssSel) => {
|
2015-05-18 14:57:20 -04:00
|
|
|
if (isPresent(cssSel.notSelector) && isBlank(cssSel.element) &&
|
|
|
|
ListWrapper.isEmpty(cssSel.classNames) && ListWrapper.isEmpty(cssSel.attrs)) {
|
2015-03-19 12:01:42 -04:00
|
|
|
cssSel.element = "*";
|
2015-05-18 14:57:20 -04:00
|
|
|
} ListWrapper.push(res, cssSel);
|
|
|
|
}
|
|
|
|
var cssSelector = new CssSelector();
|
|
|
|
var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
|
|
|
|
var match;
|
|
|
|
var current = cssSelector;
|
|
|
|
while (isPresent(match = RegExpMatcherWrapper.next(matcher))) {
|
|
|
|
if (isPresent(match[1])) {
|
|
|
|
if (isPresent(cssSelector.notSelector)) {
|
|
|
|
throw new BaseException('Nesting :not is not allowed in a selector');
|
2015-03-19 12:01:42 -04:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
current.notSelector = new CssSelector();
|
|
|
|
current = current.notSelector;
|
2015-03-19 12:01:42 -04:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
if (isPresent(match[2])) {
|
|
|
|
current.setElement(match[2]);
|
|
|
|
}
|
|
|
|
if (isPresent(match[3])) {
|
|
|
|
current.addClassName(match[3]);
|
|
|
|
}
|
|
|
|
if (isPresent(match[4])) {
|
|
|
|
current.addAttribute(match[4], match[5]);
|
|
|
|
}
|
|
|
|
if (isPresent(match[6])) {
|
|
|
|
_addResult(results, cssSelector);
|
|
|
|
cssSelector = current = new CssSelector();
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
_addResult(results, cssSelector);
|
|
|
|
return results;
|
|
|
|
}
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
constructor() {
|
|
|
|
this.element = null;
|
|
|
|
this.classNames = ListWrapper.create();
|
|
|
|
this.attrs = ListWrapper.create();
|
|
|
|
this.notSelector = null;
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
isElementSelector(): boolean {
|
|
|
|
return isPresent(this.element) && ListWrapper.isEmpty(this.classNames) &&
|
|
|
|
ListWrapper.isEmpty(this.attrs) && isBlank(this.notSelector);
|
|
|
|
}
|
2015-04-27 18:14:30 -04:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
setElement(element: string = null) {
|
|
|
|
if (isPresent(element)) {
|
|
|
|
element = element.toLowerCase();
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
this.element = element;
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
addAttribute(name: string, value: string = _EMPTY_ATTR_VALUE) {
|
|
|
|
ListWrapper.push(this.attrs, name.toLowerCase());
|
|
|
|
if (isPresent(value)) {
|
|
|
|
value = value.toLowerCase();
|
|
|
|
} else {
|
|
|
|
value = _EMPTY_ATTR_VALUE;
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
ListWrapper.push(this.attrs, value);
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
addClassName(name: string) {
|
|
|
|
ListWrapper.push(this.classNames, name.toLowerCase());
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
toString(): string {
|
|
|
|
var res = '';
|
|
|
|
if (isPresent(this.element)) {
|
|
|
|
res += this.element;
|
|
|
|
}
|
|
|
|
if (isPresent(this.classNames)) {
|
|
|
|
for (var i = 0; i < this.classNames.length; i++) {
|
|
|
|
res += '.' + this.classNames[i];
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
}
|
|
|
|
if (isPresent(this.attrs)) {
|
|
|
|
for (var i = 0; i < this.attrs.length;) {
|
|
|
|
var attrName = this.attrs[i++];
|
|
|
|
var attrValue = this.attrs[i++];
|
|
|
|
res += '[' + attrName;
|
|
|
|
if (attrValue.length > 0) {
|
|
|
|
res += '=' + attrValue;
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
res += ']';
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
if (isPresent(this.notSelector)) {
|
|
|
|
res += ":not(" + this.notSelector.toString() + ")";
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads a list of CssSelectors and allows to calculate which ones
|
|
|
|
* are contained in a given CssSelector.
|
|
|
|
*/
|
|
|
|
export class SelectorMatcher {
|
2015-05-18 14:57:20 -04:00
|
|
|
static createNotMatcher(notSelector:CssSelector) {
|
|
|
|
var notMatcher = new SelectorMatcher();
|
|
|
|
notMatcher._addSelectable(notSelector, null, null);
|
|
|
|
return notMatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _elementMap: Map<string, string>;
|
|
|
|
private _elementPartialMap: Map<string, string>;
|
|
|
|
private _classMap: Map<string, string>;
|
|
|
|
private _classPartialMap: Map<string, string>;
|
|
|
|
private _attrValueMap: Map<string, string>;
|
|
|
|
private _attrValuePartialMap: Map<string, string>;
|
|
|
|
private _listContexts: List<SelectorListContext>;
|
|
|
|
|
2014-10-28 17:46:55 -04:00
|
|
|
constructor() {
|
2014-11-11 20:33:47 -05:00
|
|
|
this._elementMap = MapWrapper.create();
|
|
|
|
this._elementPartialMap = MapWrapper.create();
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2014-11-11 20:33:47 -05:00
|
|
|
this._classMap = MapWrapper.create();
|
|
|
|
this._classPartialMap = MapWrapper.create();
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2014-11-11 20:33:47 -05:00
|
|
|
this._attrValueMap = MapWrapper.create();
|
|
|
|
this._attrValuePartialMap = MapWrapper.create();
|
2015-03-19 12:01:42 -04:00
|
|
|
|
|
|
|
this._listContexts = ListWrapper.create();
|
|
|
|
}
|
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
addSelectables(cssSelectors: List<CssSelector>, callbackCtxt: any) {
|
2015-03-19 12:01:42 -04:00
|
|
|
var listContext = null;
|
|
|
|
if (cssSelectors.length > 1) {
|
2015-05-18 14:57:20 -04:00
|
|
|
listContext = new SelectorListContext(cssSelectors);
|
2015-03-19 12:01:42 -04:00
|
|
|
ListWrapper.push(this._listContexts, listContext);
|
|
|
|
}
|
|
|
|
for (var i = 0; i < cssSelectors.length; i++) {
|
2015-05-18 14:57:20 -04:00
|
|
|
this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
|
2015-03-19 12:01:42 -04:00
|
|
|
}
|
2014-10-02 23:39:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-28 17:46:55 -04:00
|
|
|
* Add an object that can be found later on by calling `match`.
|
|
|
|
* @param cssSelector A css selector
|
2015-02-06 18:41:02 -05:00
|
|
|
* @param callbackCtxt An opaque object that will be given to the callback of the `match` function
|
2014-10-02 23:39:27 -04:00
|
|
|
*/
|
2015-05-18 14:57:20 -04:00
|
|
|
private _addSelectable(cssSelector: CssSelector, callbackCtxt: any, listContext: SelectorListContext) {
|
2014-10-28 17:46:55 -04:00
|
|
|
var matcher = this;
|
|
|
|
var element = cssSelector.element;
|
|
|
|
var classNames = cssSelector.classNames;
|
|
|
|
var attrs = cssSelector.attrs;
|
2015-03-19 12:01:42 -04:00
|
|
|
var selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
|
2015-02-06 18:41:02 -05:00
|
|
|
|
2014-10-28 17:46:55 -04:00
|
|
|
|
|
|
|
if (isPresent(element)) {
|
|
|
|
var isTerminal = attrs.length === 0 && classNames.length === 0;
|
|
|
|
if (isTerminal) {
|
|
|
|
this._addTerminal(matcher._elementMap, element, selectable);
|
|
|
|
} else {
|
|
|
|
matcher = this._addPartial(matcher._elementPartialMap, element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isPresent(classNames)) {
|
2015-05-18 14:57:20 -04:00
|
|
|
for (var index = 0; index < classNames.length; index++) {
|
2014-10-28 17:46:55 -04:00
|
|
|
var isTerminal = attrs.length === 0 && index === classNames.length - 1;
|
|
|
|
var className = classNames[index];
|
|
|
|
if (isTerminal) {
|
|
|
|
this._addTerminal(matcher._classMap, className, selectable);
|
|
|
|
} else {
|
|
|
|
matcher = this._addPartial(matcher._classPartialMap, className);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isPresent(attrs)) {
|
2015-05-18 14:57:20 -04:00
|
|
|
for (var index = 0; index < attrs.length;) {
|
2014-11-11 20:33:47 -05:00
|
|
|
var isTerminal = index === attrs.length - 2;
|
|
|
|
var attrName = attrs[index++];
|
|
|
|
var attrValue = attrs[index++];
|
2014-10-28 17:46:55 -04:00
|
|
|
var map = isTerminal ? matcher._attrValueMap : matcher._attrValuePartialMap;
|
2015-05-18 14:57:20 -04:00
|
|
|
var valuesMap = MapWrapper.get(map, attrName);
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(valuesMap)) {
|
2014-11-11 20:33:47 -05:00
|
|
|
valuesMap = MapWrapper.create();
|
|
|
|
MapWrapper.set(map, attrName, valuesMap);
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
if (isTerminal) {
|
|
|
|
this._addTerminal(valuesMap, attrValue, selectable);
|
|
|
|
} else {
|
|
|
|
matcher = this._addPartial(valuesMap, attrValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
private _addTerminal(map: Map<string, string>, name: string, selectable: SelectorContext) {
|
|
|
|
var terminalList = MapWrapper.get(map, name);
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(terminalList)) {
|
|
|
|
terminalList = ListWrapper.create();
|
2014-11-11 20:33:47 -05:00
|
|
|
MapWrapper.set(map, name, terminalList);
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
ListWrapper.push(terminalList, selectable);
|
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
private _addPartial(map: Map<string, string>, name: string) {
|
|
|
|
var matcher = MapWrapper.get(map, name);
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(matcher)) {
|
|
|
|
matcher = new SelectorMatcher();
|
2014-11-11 20:33:47 -05:00
|
|
|
MapWrapper.set(map, name, matcher);
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
return matcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the objects that have been added via `addSelectable`
|
|
|
|
* whose css selector is contained in the given css selector.
|
|
|
|
* @param cssSelector A css selector
|
|
|
|
* @param matchedCallback This callback will be called with the object handed into `addSelectable`
|
2015-03-12 04:44:49 -04:00
|
|
|
* @return boolean true if a match was found
|
2014-10-28 17:46:55 -04:00
|
|
|
*/
|
2015-05-18 14:57:20 -04:00
|
|
|
match(cssSelector: CssSelector, matchedCallback /*: (CssSelector, any) => void*/): boolean {
|
2015-03-12 04:44:49 -04:00
|
|
|
var result = false;
|
2014-10-28 17:46:55 -04:00
|
|
|
var element = cssSelector.element;
|
|
|
|
var classNames = cssSelector.classNames;
|
|
|
|
var attrs = cssSelector.attrs;
|
|
|
|
|
2015-03-19 12:01:42 -04:00
|
|
|
for (var i = 0; i < this._listContexts.length; i++) {
|
|
|
|
this._listContexts[i].alreadyMatched = false;
|
|
|
|
}
|
|
|
|
|
2015-03-12 04:44:49 -04:00
|
|
|
result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
|
2015-05-18 14:57:20 -04:00
|
|
|
result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
|
|
|
|
result;
|
2014-10-28 17:46:55 -04:00
|
|
|
|
|
|
|
if (isPresent(classNames)) {
|
2015-05-18 14:57:20 -04:00
|
|
|
for (var index = 0; index < classNames.length; index++) {
|
2014-10-28 17:46:55 -04:00
|
|
|
var className = classNames[index];
|
2015-05-18 14:57:20 -04:00
|
|
|
result =
|
|
|
|
this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
|
|
|
|
result =
|
|
|
|
this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
|
|
|
|
result;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isPresent(attrs)) {
|
2015-05-18 14:57:20 -04:00
|
|
|
for (var index = 0; index < attrs.length;) {
|
2014-11-11 20:33:47 -05:00
|
|
|
var attrName = attrs[index++];
|
|
|
|
var attrValue = attrs[index++];
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2014-11-11 20:33:47 -05:00
|
|
|
var valuesMap = MapWrapper.get(this._attrValueMap, attrName);
|
|
|
|
if (!StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
|
2015-05-18 14:57:20 -04:00
|
|
|
result =
|
|
|
|
this._matchTerminal(valuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) ||
|
|
|
|
result;
|
2014-11-11 20:33:47 -05:00
|
|
|
}
|
2015-03-12 04:44:49 -04:00
|
|
|
result = this._matchTerminal(valuesMap, attrValue, cssSelector, matchedCallback) || result;
|
2014-10-28 17:46:55 -04:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
valuesMap = MapWrapper.get(this._attrValuePartialMap, attrName);
|
2015-03-12 04:44:49 -04:00
|
|
|
result = this._matchPartial(valuesMap, attrValue, cssSelector, matchedCallback) || result;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
}
|
2015-03-12 04:44:49 -04:00
|
|
|
return result;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
_matchTerminal(map: Map<string, string>, name, cssSelector: CssSelector,
|
|
|
|
matchedCallback /*: (CssSelector, any) => void*/): boolean {
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(map) || isBlank(name)) {
|
2015-03-12 04:44:49 -04:00
|
|
|
return false;
|
|
|
|
}
|
2015-04-17 16:01:07 -04:00
|
|
|
|
2015-03-12 04:44:49 -04:00
|
|
|
var selectables = MapWrapper.get(map, name);
|
|
|
|
var starSelectables = MapWrapper.get(map, "*");
|
|
|
|
if (isPresent(starSelectables)) {
|
|
|
|
selectables = ListWrapper.concat(selectables, starSelectables);
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
if (isBlank(selectables)) {
|
2015-03-12 04:44:49 -04:00
|
|
|
return false;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
2015-02-06 18:41:02 -05:00
|
|
|
var selectable;
|
2015-03-12 04:44:49 -04:00
|
|
|
var result = false;
|
2015-05-18 14:57:20 -04:00
|
|
|
for (var index = 0; index < selectables.length; index++) {
|
2015-02-06 18:41:02 -05:00
|
|
|
selectable = selectables[index];
|
2015-03-12 04:44:49 -04:00
|
|
|
result = selectable.finalize(cssSelector, matchedCallback) || result;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
2015-03-12 04:44:49 -04:00
|
|
|
return result;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
2014-11-11 20:33:47 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
_matchPartial(map: Map<string, string>, name, cssSelector: CssSelector,
|
|
|
|
matchedCallback /*: (CssSelector, any) => void*/): boolean {
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(map) || isBlank(name)) {
|
2015-03-12 04:44:49 -04:00
|
|
|
return false;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
var nestedSelector = MapWrapper.get(map, name);
|
2014-10-28 17:46:55 -04:00
|
|
|
if (isBlank(nestedSelector)) {
|
2015-03-12 04:44:49 -04:00
|
|
|
return false;
|
2014-10-28 17:46:55 -04:00
|
|
|
}
|
|
|
|
// TODO(perf): get rid of recursion and measure again
|
|
|
|
// TODO(perf): don't pass the whole selector into the recursion,
|
|
|
|
// but only the not processed parts
|
2015-03-12 04:44:49 -04:00
|
|
|
return nestedSelector.match(cssSelector, matchedCallback);
|
2014-10-02 23:39:27 -04:00
|
|
|
}
|
|
|
|
}
|
2015-02-06 18:41:02 -05:00
|
|
|
|
|
|
|
|
2015-03-19 12:01:42 -04:00
|
|
|
class SelectorListContext {
|
|
|
|
selectors: List<CssSelector>;
|
|
|
|
alreadyMatched: boolean;
|
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
constructor(selectors: List<CssSelector>) {
|
2015-03-19 12:01:42 -04:00
|
|
|
this.selectors = selectors;
|
|
|
|
this.alreadyMatched = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 18:41:02 -05:00
|
|
|
// Store context to pass back selector and context when a selector is matched
|
|
|
|
class SelectorContext {
|
2015-05-18 14:57:20 -04:00
|
|
|
selector: CssSelector;
|
|
|
|
notSelector: CssSelector;
|
|
|
|
cbContext; // callback context
|
2015-03-19 12:01:42 -04:00
|
|
|
listContext: SelectorListContext;
|
2015-02-06 18:41:02 -05:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
constructor(selector: CssSelector, cbContext: any, listContext: SelectorListContext) {
|
2015-02-06 18:41:02 -05:00
|
|
|
this.selector = selector;
|
2015-03-12 04:44:49 -04:00
|
|
|
this.notSelector = selector.notSelector;
|
2015-02-06 18:41:02 -05:00
|
|
|
this.cbContext = cbContext;
|
2015-03-19 12:01:42 -04:00
|
|
|
this.listContext = listContext;
|
2015-02-06 18:41:02 -05:00
|
|
|
}
|
2015-03-12 04:44:49 -04:00
|
|
|
|
2015-05-18 14:57:20 -04:00
|
|
|
finalize(cssSelector: CssSelector, callback /*: (CssSelector, any) => void*/) {
|
2015-03-12 04:44:49 -04:00
|
|
|
var result = true;
|
2015-05-18 14:57:20 -04:00
|
|
|
if (isPresent(this.notSelector) &&
|
|
|
|
(isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
|
|
|
|
var notMatcher = SelectorMatcher.createNotMatcher(this.notSelector);
|
2015-03-12 04:44:49 -04:00
|
|
|
result = !notMatcher.match(cssSelector, null);
|
|
|
|
}
|
2015-05-18 14:57:20 -04:00
|
|
|
if (result && isPresent(callback) &&
|
|
|
|
(isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
|
2015-03-19 12:01:42 -04:00
|
|
|
if (isPresent(this.listContext)) {
|
|
|
|
this.listContext.alreadyMatched = true;
|
|
|
|
}
|
2015-03-12 04:44:49 -04:00
|
|
|
callback(this.selector, this.cbContext);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2015-02-06 18:41:02 -05:00
|
|
|
}
|