File tree Expand file tree Collapse file tree 4 files changed +15
-16
lines changed
Expand file tree Collapse file tree 4 files changed +15
-16
lines changed Original file line number Diff line number Diff line change 5959 "@angular/platform-browser" : " ^17.3.9" ,
6060 "@angular/platform-browser-dynamic" : " ^17.3.9" ,
6161 "ng-packagr" : " ^17.3.0" ,
62- "reflect-metadata" : " ^0.2.2" ,
6362 "typescript" : " 5.4.5" ,
6463 "vitest" : " ^1.6.0"
6564 },
Original file line number Diff line number Diff line change @@ -73,10 +73,11 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
7373 ) { }
7474
7575 ngOnChanges ( changes : SimpleChanges ) {
76+ console . log ( 'changes' , changes )
7677 if ( changes [ 'content' ] ) {
7778 this . renderFlags |= FlexRenderFlags . ContentChanged
7879 }
79- if ( ! changes [ 'content' ] && changes [ 'props' ] ) {
80+ if ( changes [ 'props' ] ) {
8081 this . renderFlags |= FlexRenderFlags . PropsReferenceChanged
8182 }
8283 this . checkView ( )
@@ -98,10 +99,9 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
9899 }
99100
100101 const contentToRender = this . #getContentValue( this . props )
102+
101103 if ( contentToRender . kind === 'null' || ! this . renderView ) {
102- // Whether the content is null or view has not been rendered, we set contentChanged
103- // flag in order to re-initialize everything via the `render` method;
104- this . renderFlags |= FlexRenderFlags . ContentChanged
104+ this . renderFlags = FlexRenderFlags . Creation
105105 } else {
106106 this . renderView . setContent ( contentToRender . content )
107107 const previousContentInfo = this . renderView . previousContent
@@ -116,7 +116,10 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
116116 }
117117
118118 checkView ( ) {
119- if ( this . renderFlags & FlexRenderFlags . ContentChanged ) {
119+ if (
120+ this . renderFlags &
121+ ( FlexRenderFlags . ContentChanged | FlexRenderFlags . Creation )
122+ ) {
120123 this . render ( )
121124 return
122125 }
Original file line number Diff line number Diff line change 11export enum FlexRenderFlags {
22 /**
3- * Whether the view has been created.
3+ * Whether the view has not been created yet or the current view will be cleared during the update phase .
44 */
55 Creation = 1 << 0 ,
66 /**
7- * Whether the `content` property has changed.
7+ * Whether the `content` property has changed or the view need a complete re-rendering .
88 * When this flag is enabled, the view is recreated from scratch after clearing the previous one.
99 */
1010 ContentChanged = 1 << 1 ,
1111 /**
12- * Whether the `props` property has changed.
13- * When this flag is enabled, the view context is updated based on the type of the content:
14- * - Component view: inputs will be updated and view will be marked as dirty
15- * - TemplateRef | primitive values: view will be marked as dirty
12+ * Whether the `props` property reference has changed.
13+ * When this flag is enabled, the view context is updated based on the type of the content.
14+ *
15+ * For Component view, inputs will be updated and view will be marked as dirty.
16+ * For TemplateRef and primitive values, view will be marked as dirty
1617 */
1718 PropsReferenceChanged = 1 << 2 ,
1819 /**
1920 * Whether the current rendered view has to be dirty checked.
20- * When this flag is enabled, the view will be updated based on it's type.
2121 */
2222 DirtyCheck = 1 << 3 ,
2323}
You can’t perform that action at this time.
0 commit comments