This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

data

Summary

Gets the text affected by the composition event.

Property of dom/CompositionEventdom/CompositionEvent

Syntax

Note: This property is read-only.

var compositionData = event.html/elements/data;

Return Value

Returns an object of type StringString

The text affected by the event. See the notes for event specific values.

Examples

function getCompEventText(e) {
//retrieve text for composition event
var compEventText = e.data;
return compEventText;
}

Notes

The value varies by the event type:

  • For compositionstart - the text that was selected.
  • For compositionupdate - the current text.
  • For compositionend - the text that will be committed.

If a user cancels a composition event, the data attribute is set to null on the final compositionupdate event.

Related specifications

W3C HTML5
Working Draft
WHATWG HTML
Living Standard

See also

Related pages

Attributions