feat: filter

This commit is contained in:
DarkSky
2022-08-24 18:07:00 +08:00
parent 6ac1f618f0
commit e19470397e
+6 -5
View File
@@ -199,13 +199,11 @@ export class AbstractBlock<
const states: Map<string, 'update' | 'delete'> = new Map([ const states: Map<string, 'update' | 'delete'> = new Map([
[parentId, type], [parentId, type],
]); ]);
for (const listener of this._listeners.parent.values()) { this[_EMIT_EVENT]('parent', states);
listener(states);
}
} }
[_EMIT_EVENT]( [_EMIT_EVENT](
event: 'cascade' | 'content' | 'children', event: 'cascade' | 'content' | 'children' | 'parent',
states: Parameters<BlockListener>[0] states: Parameters<BlockListener>[0]
) { ) {
const listeners = this._listeners[event]; const listeners = this._listeners[event];
@@ -214,7 +212,10 @@ export class AbstractBlock<
listener(states); listener(states);
} }
} }
this._parent?.[_EMIT_EVENT]('cascade', states);
if (['children', 'content'].includes(event)) {
this._parent?.[_EMIT_EVENT]('cascade', states);
}
} }
private _refreshParent(parent: AbstractBlock<B, C>) { private _refreshParent(parent: AbstractBlock<B, C>) {