refactor(ivy): Remove TNode.directives
in favor of TData
(#35050)
`TNode.directives` was introduced in https://github.com/angular/angular/pull/34938. Turns out that it is unnecessary because the information is already present it `TData` when combining with `TNode.directiveStart` and `TNode.directiveEnd` Mainly this is true (conceptually): ``` expect(tNode.directives).toEqual( tData.slice( tNode.directivesStart, tNode.directivesEnd - tNode.DirectivesStart -1 ) ); ``` The refactoring removes `TNode.directives` and adds `TNode.directiveStyling` as we still need to keep location in the directive in `TNode` PR Close #35050
This commit is contained in:

committed by
Miško Hevery

parent
65dbd50594
commit
01308e4c7c
@ -9,7 +9,7 @@
|
||||
import {DirectiveDef} from '@angular/core/src/render3';
|
||||
import {ɵɵdefineDirective} from '@angular/core/src/render3/definition';
|
||||
import {classStringParser, styleStringParser, toStylingKeyValueArray, ɵɵclassProp, ɵɵstyleMap, ɵɵstyleProp, ɵɵstyleSanitizer} from '@angular/core/src/render3/instructions/styling';
|
||||
import {AttributeMarker, TAttributes, TDirectiveDefs} from '@angular/core/src/render3/interfaces/node';
|
||||
import {AttributeMarker, TAttributes} from '@angular/core/src/render3/interfaces/node';
|
||||
import {StylingRange, TStylingKey, TStylingRange, getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate, setTStylingRangeNext, setTStylingRangePrev, toTStylingRange} from '@angular/core/src/render3/interfaces/styling';
|
||||
import {HEADER_OFFSET, TVIEW} from '@angular/core/src/render3/interfaces/view';
|
||||
import {getLView, leaveView, setBindingRootForHostBindings} from '@angular/core/src/render3/state';
|
||||
@ -520,13 +520,13 @@ class MockDir {}
|
||||
function givenDirectiveAttrs(tAttrs: TAttributes[]) {
|
||||
const tNode = getTNode();
|
||||
const tData = getTData();
|
||||
const directives: TDirectiveDefs = tNode.directives = [0];
|
||||
tNode.directiveStart = getTDataIndexFromDirectiveIndex(0);
|
||||
tNode.directiveEnd = getTDataIndexFromDirectiveIndex(tAttrs.length);
|
||||
for (let i = 0; i < tAttrs.length; i++) {
|
||||
const tAttr = tAttrs[i];
|
||||
const directiveDef = ɵɵdefineDirective({type: MockDir, hostAttrs: tAttr}) as DirectiveDef<any>;
|
||||
applyTAttributes(directiveDef.hostAttrs);
|
||||
tData[getTDataIndexFromDirectiveIndex(i)] = directiveDef;
|
||||
directives.push(directiveDef);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user