Skip to content

Popover: spec for dealing with element removal is incorrect #9161

Description

@jakearchibald

https://html.spec.whatwg.org/multipage/infrastructure.html#dom-trees:hide-popover-algorithm

When a popover is removed from the DOM, it calls the hide popover algorithm.

That algorithm will always exit on step 1, since the removed element is no longer connected to the document.

Activity

  1. added
    topic: popover
    on Apr 13, 2023
  2. jakearchibald commented on Apr 13, 2023

    @jakearchibald
    ContributorAuthor

    I think the behaviour here needs some design. Does it make sense to fire all of the events in this case?

  3. mfreed7 commented on Apr 14, 2023

    @mfreed7
    Contributor

    I agree that the spec is broken for this case. The difference between the spec and at least the Chromium implementation is that the spec for remove runs the removing steps at step 15, but removes the node from the tree before that, at step 11. The Chromium impl runs that call to HidePopoverInternal before the node is removed from the tree.

    I'm not sure what the best way to fix the spec is. Seems like there might need to be "before removing steps" added before step 11 or something? @josepharhar @annevk @nt1m

  4. mfreed7 commented on Apr 14, 2023

    @mfreed7
    Contributor

    Does it make sense to fire all of the events in this case?

    We discussed this at great length during the spec PR review. The problem is that events can't be fired synchronously during removal, so we'd have to queue the events in this case, which leads to myriad problems like out of order events. So we decided that the best course of action was not firing events in this case.

  5. nt1m commented on Apr 14, 2023

    @nt1m
    Member

    Yes, WebKit also runs removing steps before removing the node from the tree. That part of the spec is definitely broken here.

  6. added a commit that references this issue on Apr 17, 2023
  7. josepharhar commented on Apr 17, 2023

    @josepharhar
    Contributor

    I opened a DOM PR to add "before removing steps" that can hook into here: whatwg/dom#1185

  8. josepharhar commented on Jun 26, 2023

    @josepharhar
    Contributor

    I opened an HTML PR which should make the above DOM PR obsolete by fixing this bug in a different way #9457

  9. added a commit that references this issue on Oct 7, 2026
    efc54f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: popover

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions