Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch cancel event to refine bubbling information #1220

Merged
merged 1 commit into from
Apr 22, 2024
Merged

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented Apr 19, 2024

As discussed in #1212, the cancel event bubbles on HTMLInputElement, but it does not bubble on HTMLDialogElement. It does not bubble on CloseWatcher either but that's because CloseWatcher is not part of a bubbling tree.

Events extraction cannot automatically get this nuance, be it only because it only sees HTMLElement as target interface for the event, and not HTMLInputElement and HTMLDialogElement. In practice, it claims that the event bubbles, which is neither wrong nor right.

This patch restricts the cancel entry in the HTML events extract to only target HTMLInputElement, in order to create the right bubbling entry. And it creates another cancel entry which does not bubble for HTMLDialogElement and CloseWatcher.

With this patch (and the new version of Reffy), we should end up with the following entry in the consolidated events.json file, which captures the fact that:

  • the event bubbles on HTMLInputElement
  • the event does not bubble on HTMLDialogElement
  • the concept of bubbling is meaningless on CloseWatcher
{
  "href": "https://html.spec.whatwg.org/multipage/indices.html#event-cancel",
  "src": {
    "format": "summary table",
    "href": "https://html.spec.whatwg.org/multipage/indices.html#event-cancel"
  },
  "type": "cancel",
  "targets": [
    {
      "target": "HTMLInputElement",
      "bubbles": true,
      "bubblingPath": [
        "Node",
        "Document",
        "Window"
      ]
    },
    {
      "target": "CloseWatcher"
    },
    {
      "target": "HTMLDialogElement",
      "bubbles": false
    }
  ],
  "interface": "Event"
}

As discussed in #1212, the `cancel` event bubbles on `HTMLInputElement`,
but it does not bubble on `HTMLDialogElement`. It does not bubble on
`CloseWatcher` either but that's because `CloseWatcher` is not part of a
bubbling tree in any case.

Events extraction cannot automatically get this nuance, be it only because it
only sees `HTMLElement` as target interface for the event, and not
`HTMLInputElement` and `HTMLDialogElement`. In practice, it claims that the
event bubbles, which is neither wrong nor right.

This patch restricts the `cancel` entry in the HTML events extract to only
target `HTMLInputElement`, in order to create the right bubbling entry. And
it creates another `cancel` entry which does not bubble for `HTMLDialogElement`
and `CloseWatcher`.

With this patch (and the new version of Reffy), we should end up with the
following entry in the consolidated `events.json` file, which captures the
fact that:
- the event bubbles on `HTMLInputElement`
- the event does not bubble on `HTMLDialogElement`
- the concept of bubbling is meaningless on `CloseWatcher`

```json
{
  "href": "https://html.spec.whatwg.org/multipage/indices.html#event-cancel",
  "src": {
    "format": "summary table",
    "href": "https://html.spec.whatwg.org/multipage/indices.html#event-cancel"
  },
  "type": "cancel",
  "targets": [
    {
      "target": "HTMLInputElement",
      "bubbles": true,
      "bubblingPath": [
        "Node",
        "Document",
        "Window"
      ]
    },
    {
      "target": "CloseWatcher"
    },
    {
      "target": "HTMLDialogElement",
      "bubbles": false
    }
  ],
  "interface": "Event"
}
```
@tidoust tidoust requested a review from dontcallmedom April 19, 2024 16:48
@tidoust tidoust merged commit 8a4f7c4 into main Apr 22, 2024
1 check passed
@tidoust tidoust deleted the patch-cancel-event branch April 22, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants