refactor(ivy): define new AttributeMarker.Template marker (#29041)

This commit adds a new `AttributeMarker` type that will be used, in a
future commit, to mark attributes as coming from an inline-template
expansion, rather than the element that is being contained in the template.

PR Close #29041
This commit is contained in:
Pete Bacon Darwin
2019-03-07 08:31:31 +00:00
committed by Kara Erickson
parent 423ac01dcf
commit e3a401d20c
7 changed files with 106 additions and 10 deletions

View File

@ -17,7 +17,7 @@ import {getComponentDef, getDirectiveDef, getPipeDef} from './definition';
import {NG_ELEMENT_ID} from './fields';
import {DirectiveDef} from './interfaces/definition';
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
import {AttributeMarker, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType} from './interfaces/node';
import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType, isNameOnlyAttributeMarker} from './interfaces/node';
import {DECLARATION_VIEW, INJECTOR, LView, TData, TVIEW, TView, T_HOST} from './interfaces/view';
import {assertNodeOfPossibleTypes} from './node_assert';
import {getLView, getPreviousOrParentTNode, setTNodeAndViewData} from './state';
@ -272,9 +272,10 @@ export function injectAttributeImpl(tNode: TNode, attrNameToInject: string): str
if (attrs) {
for (let i = 0; i < attrs.length; i = i + 2) {
const attrName = attrs[i];
if (attrName === AttributeMarker.Bindings) break;
// TODO: What happens here if an attribute has a namespace?
// TODO: What happens here if the attribute name happens to match a CSS class or style?
// If we hit a `Bindings` or `Template` marker then we are done.
if (isNameOnlyAttributeMarker(attrName)) break;
// TODO(FW-1137): Skip namespaced attributes
// TODO(FW-1139): supports classes/styles in @Attribute injection
if (attrName == attrNameToInject) {
return attrs[i + 1] as string;
}