Skip to content

specify how compositionend works if the caret has been moved to a different element  #5

Description

@johanneswilm

If one moves the caret/selection to a different element when compoisitionstart is triggered, browsers different on compositionend:

  1. Chrome/Safari trigger the compositionend event on the element where composition takes place.
  2. Firefox triggers the compositionend event on the element where the caret was at the time when the compositionstart event was triggered.

Additionally, browsers behave differently if the caret is moved to a different element when compositionend is triggered:

  1. Chrome/Safari paste the composed characters in the place where the caret is moved to.
  2. Firefox moves the caret to a different element and inserts no characters there by default. If the JS inserts the characters by means of execCommand/insertHTML, the endComposition event is triggered a second time.

The Chrome/Safari behavior is desired for the use case where one wants to have IME character insertion into the document stream be atomic -- either by doing composition somewhere else [1] or by using a Shadow DOM during composition [2].

[1] http://jsbin.com/wimuqowimu/15/edit?html,js,console,output (works in Chrome/FF)
[2] http://jsbin.com/pacisugiwu/1/edit?html,js,output (only works in Chrome)

Edge behavior is close to FF behavior and Safari close to Chrome.

See also debate about this here: https://lists.w3.org/Archives/Public/www-dom/2015JulSep/0044.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions