From b73e02005b1f4776064ca5988026a5e107dc93b3 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 7 Mar 2019 08:31:30 +0000 Subject: [PATCH] refactor: rename `matchingSelectorIndex` to `matchingProjectionSelectorIndex` (#29041) The previous name was ambiguous as there are different strategies for matching selectors depending upon the scenario. PR Close #29041 --- packages/core/src/render3/instructions.ts | 7 ++++--- packages/core/src/render3/node_selector_matcher.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 495c26b244..224b21e78c 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -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 {assertNodeOfPossibleTypes, assertNodeType} from './node_assert'; 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 {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'; @@ -2558,8 +2558,9 @@ export function projectionDef(selectors?: CssSelectorList[], textSelectors?: str let componentChild: TNode|null = componentNode.child; while (componentChild !== null) { - const bucketIndex = - selectors ? matchingSelectorIndex(componentChild, selectors, textSelectors !) : 0; + const bucketIndex = selectors ? + matchingProjectionSelectorIndex(componentChild, selectors, textSelectors !) : + 0; if (tails[bucketIndex]) { tails[bucketIndex] !.projectionNext = componentChild; diff --git a/packages/core/src/render3/node_selector_matcher.ts b/packages/core/src/render3/node_selector_matcher.ts index 9fcc32cfa7..aabd4d61e9 100644 --- a/packages/core/src/render3/node_selector_matcher.ts +++ b/packages/core/src/render3/node_selector_matcher.ts @@ -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). * * 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. */ -export function matchingSelectorIndex( +export function matchingProjectionSelectorIndex( tNode: TNode, selectors: CssSelectorList[], textSelectors: string[]): number { const ngProjectAsAttrVal = getProjectAsAttrValue(tNode); for (let i = 0; i < selectors.length; i++) {