perf(ivy): remove global state access from setUpAttributes (#32041)

PR Close #32041
This commit is contained in:
Pawel Kozlowski 2019-08-07 17:13:59 +02:00 committed by Alex Rickabaugh
parent 4689ea2727
commit a06043b703
2 changed files with 5 additions and 8 deletions

View File

@ -58,7 +58,7 @@ export function ɵɵelementStart(
getOrCreateTNode(tView, lView[T_HOST], index, TNodeType.Element, name, attrs || null);
if (attrs != null) {
const lastAttrIndex = setUpAttributes(native, attrs);
const lastAttrIndex = setUpAttributes(renderer, native, attrs);
if (tView.firstTemplatePass) {
registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);
}
@ -209,7 +209,7 @@ export function ɵɵelementHostAttrs(attrs: TAttributes) {
// errors...
if (tNode.type === TNodeType.Element) {
const native = getNativeByTNode(tNode, lView) as RElement;
const lastAttrIndex = setUpAttributes(native, attrs);
const lastAttrIndex = setUpAttributes(lView[RENDERER], native, attrs);
if (tView.firstTemplatePass) {
const stylingNeedsToBeRendered = registerInitialStylingOnTNode(tNode, attrs, lastAttrIndex);

View File

@ -7,9 +7,7 @@
*/
import {AttributeMarker, TAttributes} from '../interfaces/node';
import {CssSelector} from '../interfaces/projection';
import {ProceduralRenderer3, RElement, isProceduralRenderer} from '../interfaces/renderer';
import {RENDERER} from '../interfaces/view';
import {getLView} from '../state';
import {ProceduralRenderer3, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
/**
@ -34,13 +32,12 @@ import {getLView} from '../state';
* Note that this instruction does not support assigning style and class values to
* an element. See `elementStart` and `elementHostAttrs` to learn how styling values
* are applied to an element.
*
* @param renderer The renderer to be used
* @param native The element that the attributes will be assigned to
* @param attrs The attribute array of values that will be assigned to the element
* @returns the index value that was last accessed in the attributes array
*/
export function setUpAttributes(native: RElement, attrs: TAttributes): number {
const renderer = getLView()[RENDERER];
export function setUpAttributes(renderer: Renderer3, native: RElement, attrs: TAttributes): number {
const isProc = isProceduralRenderer(renderer);
let i = 0;