demo · v143

InputEvent.dataTransfer

Paste, drop, or accept replacement text in the editors below. The important v143 change is on the input event: beforeinput already carried dataTransfer, while input now carries the same payload for contenteditable hosts.

Prototype getterchecking

Constructed input eventchecking

Form-control scopetextarea/input should keep dataTransfer null

Contenteditable host

This editor logs both beforeinput and input. Try pasting rich text, dropping a snippet, or replacing somthing with a spell-check suggestion.

Expected v143+ path: beforeinput.dataTransfer and input.dataTransfer are both populated for paste, drop, and replacement.

Textarea control

Expected path: input.data may contain inserted text, but input.dataTransfer remains null.

beforeinput events

    input events

      the call

      const interesting = new Set([
        "insertFromPaste",
        "insertFromDrop",
        "insertReplacementText",
      ]);
      
      editor.addEventListener("beforeinput", report);
      editor.addEventListener("input", report);
      
      function report(event) {
        if (!interesting.has(event.inputType)) return;
      
        // v143: input.dataTransfer matches the payload that beforeinput had.
        const payload = event.dataTransfer;
        const plain = payload?.getData("text/plain");
      }

      see also