[whatwg/dom] Element's display property affects composedPath() calculation unexpectedly (Issue #1419)

f820602h created an issue (whatwg/dom#1419)

### What is the issue with the DOM Standard?

I must be honest and say I'm not sure if I can ask this question here, but when searching for relevant documentation, all clues seem to point to this place.

Below is a minimal reproducible example of the phenomenon.

```html
<html lang="en">
  <head>
    <style>
      .box {
        width: 300px;
        margin: 0 auto;
        border: 1px solid black;
        padding: 24px;
        border-radius: 4px;
        background-color: #f1f1f1;
      }

      .loading {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 30000;
        background-color: rgba(0, 0, 0, 0.2);
      }

      .loading.show {
        display: block;
      }
    </style>
  </head>
  <body>
    <div class="out">
      <div class="box">
        <h1>HELLO WORLD !</h1>
      </div>
      <div class="loading">test</div>
    </div>

    <script>
      const loading = document.querySelector(".loading");

      window.setInterval(() => {
        loading.classList.toggle("show");
      }, 1000);

      function debug(e) {
        console.log(e.composedPath()[0]);
      }

      window.addEventListener("click", debug);
    </script>
  </body>
</html>
```

I created this HTML structure and JS logic, and continuously clicked on the location where `.box`  is in the browser. I originally expected this behavior to cause the result printed by `composedPath()[0]` to alternate between the two elements `.box` and `.loading`, but surprisingly, `.out` appeared in between.

https://github.com/user-attachments/assets/2f3f1396-dc03-4be8-bdd2-f2660a7b5b38

After reading the [Spec](https://htmlspecs.com/dom/#dispatching-events) and this issues #525 , I understood the relationship between composedPath and Shadow DOM, but I cannot explain how an element's display property affects this calculation result.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1419
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1419@github.com>

Received on Wednesday, 5 November 2025 09:41:27 UTC