Skip to content

Html.map + blur event on DOM removal makes impossible states possible #103

@zwilias

Description

@zwilias

SSCCE

https://ellie-app.com/3Fs3Jr2XMPpa1/0

Problem

Chrome triggers a blur event when removing a DOM node that has focus. If that DOM node happens to be the child of a node that is subject to a p-tagger patch, then the tagger will have changed by the time the DOM node is removed and, hence, get tagged with the wrong tagger.

Firefox has had a bug open for the past 7 years to add the same behaviour (https://bugzilla.mozilla.org/show_bug.cgi?id=559561)

Other browsers don't seem to exhibit this behaviour. The spec is quite vague on what this should do.

Workarounds

  • ensuring the number of taggers is different. This can be done using Html.map identity.
  • ensuring the Html.map tree isn't reused by using Html.Keyed nodes.

Possible solutions include:

  • removing all eventlisteners before removing a node.
  • reverting to p-redraw if the taggers changed at all.

This is issue was already (partially) reported in #73 but doesn't really have anything to do with Html.lazy. Since it came up today in Slack, I figured I'd investigate a little and report my findings here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions