MCPcopy
hub / github.com/angular/angular / match

Method match

packages/compiler/src/directive_matching.ts:340–390  ·  view source on GitHub ↗

* 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` * @return boolean true if a match

(
    cssSelector: CssSelector,
    matchedCallback: ((c: CssSelector, a: T) => void) | null,
  )

Source from the content-addressed store, hash-verified

338 * @return boolean true if a match was found
339 */
340 match(
341 cssSelector: CssSelector,
342 matchedCallback: ((c: CssSelector, a: T) => void) | null,
343 ): boolean {
344 let result = false;
345 const element = cssSelector.element!;
346 const classNames = cssSelector.classNames;
347 const attrs = cssSelector.attrs;
348
349 for (let i = 0; i < this._listContexts.length; i++) {
350 this._listContexts[i].alreadyMatched = false;
351 }
352
353 result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
354 result =
355 this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) || result;
356
357 if (classNames) {
358 for (let i = 0; i < classNames.length; i++) {
359 const className = classNames[i];
360 result =
361 this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
362 result =
363 this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
364 result;
365 }
366 }
367
368 if (attrs) {
369 for (let i = 0; i < attrs.length; i += 2) {
370 const name = attrs[i];
371 const value = attrs[i + 1];
372
373 const terminalValuesMap = this._attrValueMap.get(name)!;
374 if (value) {
375 result =
376 this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;
377 }
378 result =
379 this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
380
381 const partialValuesMap = this._attrValuePartialMap.get(name)!;
382 if (value) {
383 result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;
384 }
385 result =
386 this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
387 }
388 }
389 return result;
390 }
391
392 /** @internal */
393 _matchTerminal(

Callers 15

executeMethod · 0.95
_parseTemplateBindingsFunction · 0.45
keyframes_spec.tsFile · 0.45
output_jit_spec.tsFile · 0.45
nbSegmentsPerLineFunction · 0.45
selector_spec.tsFile · 0.45
shimCssTextMethod · 0.45
_scopeSelectorPartMethod · 0.45

Calls 3

_matchTerminalMethod · 0.95
_matchPartialMethod · 0.95
getMethod · 0.65

Tested by 1