refactor(ivy): get rid of styling cleanup functions outside of styling code (#32591)
Prior to this patch, each time `advance()` would run (or when a templateFn or hostBindings code exits) then the core change detection code would check to see whether the styling data needs to be reset. This patch removes that functionality and places everything inside of the scheduled styling exit function. This means that each time one or more styling bindings run (even if the value hasn't changed) then an exit function will be scheduled and that will do all the cleanup. PR Close #32591
This commit is contained in:

committed by
Andrew Kushnir

parent
4f41473048
commit
a2e890e4f7
@ -12,8 +12,7 @@ import {assertDefined} from '../util/assert';
|
||||
import {assertLViewOrUndefined} from './assert';
|
||||
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
||||
import {TElementNode, TNode, TViewNode} from './interfaces/node';
|
||||
import {CONTEXT, DECLARATION_VIEW, LView, OpaqueViewState, TVIEW} from './interfaces/view';
|
||||
import {resetStylingState} from './styling_next/state';
|
||||
import {CONTEXT, DECLARATION_VIEW, LView, OpaqueViewState} from './interfaces/view';
|
||||
|
||||
|
||||
/**
|
||||
@ -144,8 +143,7 @@ let activeDirectiveId = 0;
|
||||
export const enum ActiveElementFlags {
|
||||
Initial = 0b00,
|
||||
RunExitFn = 0b01,
|
||||
ResetStylesOnExit = 0b10,
|
||||
Size = 2,
|
||||
Size = 1,
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,9 +172,6 @@ export function setActiveHostElement(elementIndex: number | null = null) {
|
||||
if (hasActiveElementFlag(ActiveElementFlags.RunExitFn)) {
|
||||
executeElementExitFn();
|
||||
}
|
||||
if (hasActiveElementFlag(ActiveElementFlags.ResetStylesOnExit)) {
|
||||
resetStylingState();
|
||||
}
|
||||
setSelectedIndex(elementIndex === null ? -1 : elementIndex);
|
||||
activeDirectiveId = 0;
|
||||
}
|
||||
@ -390,6 +385,10 @@ export function setCurrentQueryIndex(value: number): void {
|
||||
* @returns the previously active lView;
|
||||
*/
|
||||
export function selectView(newView: LView, hostTNode: TElementNode | TViewNode | null): LView {
|
||||
if (hasActiveElementFlag(ActiveElementFlags.RunExitFn)) {
|
||||
executeElementExitFn();
|
||||
}
|
||||
|
||||
ngDevMode && assertLViewOrUndefined(newView);
|
||||
const oldView = lView;
|
||||
|
||||
|
Reference in New Issue
Block a user