- From: Carlos Lopez <notifications@github.com>
- Date: Tue, 06 Apr 2021 16:22:01 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/583/814495296@github.com>
Deno actually uses a somewhat custom method of "get the parent" that allows custom overloading. The check occurs by checking if the `EventTarget` "is a node" by checking if has a `nodeType` property. Then it uses `.parentNode`. That means an Javascript Object that has `nodeType` can potentially return a parent (via `.parentNode`). https://github.com/denoland/deno/blob/704e1e53307130012da974f42d2cad94e07b5664/op_crates/web/02_event.js#L438 This is piggybacking off `Node`, but to write a proper shim for it (I've tried it), you have to implement `Node`, `ChildNode`, `ParentNode`, `Document`. and some others that my escape me at the moment. That would be a lot of work for user agents to include and force them to require support something far more complicated just `EventTarget`. The Deno is using something custom as is for lack of a standard, and I can totally understand doing it like that instead of writing all of `Document`. I can only realistically conclude that the EventTarget may be constructed with a `eventTargetInit` object that may have a `get the parent` value. So you can maybe do something like `new EventTarget({ getParent: myMasterParentFn })`, for example. It keeps it strictly within `EventTarget` without telling user agents to write more code, or having developers need to add on something heavy like JSDom. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/583#issuecomment-814495296
Received on Tuesday, 6 April 2021 23:22:14 UTC