Re: [whatwg/dom] Do not dispatch a trusted event when target and reletedTarget are identical (#336)

> Ah, I see. Okay to remove `isTrusted` guard since we added "target is not event's relatedTarget" guard. That would change the behavior slightly, but at least it would not bring an incompatible change unless Shadow DOM is used.
> 
> I can add tests for WPT. Thank you!

@hayatoito Well, I've read your issue, I see you avoided in spec using `isTrusted` property, instead this you added "target is not event's relatedTarget". 

```JavaScript
/// Let "target" be the host of a shadow root in an another shadow root
const ev = new Event("click");
ev.relatedTarget = target;
target.addEventListener("click", (e) => console.log(e));
target.dispatchEvent(ev)
```
This example will invoke callback but it shouldn't because condition returns `true`.

I see that browsers don't call callbacks if it conform that condition if it is not synthetic event and call if it is synthetic event.
> If target is relatedTarget and target is not event’s [relatedTarget](https://web.archive.org/web/20161021131512/https://dom.spec.whatwg.org/#event-relatedtarget), then return true.

Could you give some comment about that?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/336#issuecomment-1466400600
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/336/c1466400600@github.com>

Received on Monday, 13 March 2023 15:47:31 UTC