原文
export class Context<T extends record> extends EventTarget {
#dispatch(type: string, detail: Omit<detail, "type">) {
Object.assign(detail, { type })
this.dispatchEvent(new Context.Event(type, { detail }))
if ((type === "set") || (type === "delete") || (type === "call")) {
this.dispatchEvent(new Context.Event("change", { detail }))
}
for (const child of this.#children) {
if (!Reflect.has(child.#target, detail.path[0] ?? detail.property)) {
child.#dispatch(type, detail)
}
}
}
}