Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: rename matchingSelectorIndex to `matchingProjectionSelect…
…orIndex` (#29041)

The previous name was ambiguous as there are different strategies
for matching selectors depending upon the scenario.

PR Close #29041
  • Loading branch information
petebacondarwin authored and kara committed Mar 7, 2019
1 parent 9a19592 commit b73e020
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/render3/instructions.ts
Expand Up @@ -38,7 +38,7 @@ import {StylingContext} from './interfaces/styling';
import {BINDING_INDEX, CHILD_HEAD, CHILD_TAIL, CLEANUP, CONTEXT, DECLARATION_VIEW, ExpandoInstructions, FLAGS, HEADER_OFFSET, HOST, INJECTOR, InitPhaseState, LView, LViewFlags, NEXT, OpaqueViewState, PARENT, QUERIES, RENDERER, RENDERER_FACTORY, RootContext, RootContextFlags, SANITIZER, TData, TVIEW, TView, T_HOST} from './interfaces/view'; import {BINDING_INDEX, CHILD_HEAD, CHILD_TAIL, CLEANUP, CONTEXT, DECLARATION_VIEW, ExpandoInstructions, FLAGS, HEADER_OFFSET, HOST, INJECTOR, InitPhaseState, LView, LViewFlags, NEXT, OpaqueViewState, PARENT, QUERIES, RENDERER, RENDERER_FACTORY, RootContext, RootContextFlags, SANITIZER, TData, TVIEW, TView, T_HOST} from './interfaces/view';
import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert'; import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
import {appendChild, appendProjectedNodes, createTextNode, insertView, removeView} from './node_manipulation'; import {appendChild, appendProjectedNodes, createTextNode, insertView, removeView} from './node_manipulation';
import {isNodeMatchingSelectorList, matchingSelectorIndex} from './node_selector_matcher'; import {isNodeMatchingSelectorList, matchingProjectionSelectorIndex} from './node_selector_matcher';
import {applyOnCreateInstructions} from './node_util'; import {applyOnCreateInstructions} from './node_util';
import {decreaseElementDepthCount, enterView, getBindingsEnabled, getCheckNoChangesMode, getContextLView, getCurrentDirectiveDef, getElementDepthCount, getIsParent, getLView, getPreviousOrParentTNode, increaseElementDepthCount, isCreationMode, leaveView, nextContextImpl, resetComponentState, setBindingRoot, setCheckNoChangesMode, setCurrentDirectiveDef, setCurrentQueryIndex, setIsParent, setPreviousOrParentTNode} from './state'; import {decreaseElementDepthCount, enterView, getBindingsEnabled, getCheckNoChangesMode, getContextLView, getCurrentDirectiveDef, getElementDepthCount, getIsParent, getLView, getPreviousOrParentTNode, increaseElementDepthCount, isCreationMode, leaveView, nextContextImpl, resetComponentState, setBindingRoot, setCheckNoChangesMode, setCurrentDirectiveDef, setCurrentQueryIndex, setIsParent, setPreviousOrParentTNode} from './state';
import {getInitialClassNameValue, getInitialStyleStringValue, initializeStaticContext as initializeStaticStylingContext, patchContextWithStaticAttrs, renderInitialClasses, renderInitialStyles, renderStyling, updateClassProp as updateElementClassProp, updateContextWithBindings, updateStyleProp as updateElementStyleProp, updateStylingMap} from './styling/class_and_style_bindings'; import {getInitialClassNameValue, getInitialStyleStringValue, initializeStaticContext as initializeStaticStylingContext, patchContextWithStaticAttrs, renderInitialClasses, renderInitialStyles, renderStyling, updateClassProp as updateElementClassProp, updateContextWithBindings, updateStyleProp as updateElementStyleProp, updateStylingMap} from './styling/class_and_style_bindings';
Expand Down Expand Up @@ -2558,8 +2558,9 @@ export function projectionDef(selectors?: CssSelectorList[], textSelectors?: str
let componentChild: TNode|null = componentNode.child; let componentChild: TNode|null = componentNode.child;


while (componentChild !== null) { while (componentChild !== null) {
const bucketIndex = const bucketIndex = selectors ?
selectors ? matchingSelectorIndex(componentChild, selectors, textSelectors !) : 0; matchingProjectionSelectorIndex(componentChild, selectors, textSelectors !) :
0;


if (tails[bucketIndex]) { if (tails[bucketIndex]) {
tails[bucketIndex] !.projectionNext = componentChild; tails[bucketIndex] !.projectionNext = componentChild;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/render3/node_selector_matcher.ts
Expand Up @@ -209,13 +209,13 @@ export function getProjectAsAttrValue(tNode: TNode): string|null {
} }


/** /**
* Checks a given node against matching selectors and returns * Checks a given node against matching projection selectors and returns
* selector index (or 0 if none matched). * selector index (or 0 if none matched).
* *
* This function takes into account the ngProjectAs attribute: if present its value will be compared * This function takes into account the ngProjectAs attribute: if present its value will be compared
* to the raw (un-parsed) CSS selector instead of using standard selector matching logic. * to the raw (un-parsed) CSS selector instead of using standard selector matching logic.
*/ */
export function matchingSelectorIndex( export function matchingProjectionSelectorIndex(
tNode: TNode, selectors: CssSelectorList[], textSelectors: string[]): number { tNode: TNode, selectors: CssSelectorList[], textSelectors: string[]): number {
const ngProjectAsAttrVal = getProjectAsAttrValue(tNode); const ngProjectAsAttrVal = getProjectAsAttrValue(tNode);
for (let i = 0; i < selectors.length; i++) { for (let i = 0; i < selectors.length; i++) {
Expand Down

0 comments on commit b73e020

Please sign in to comment.