Skip to content

Use OpaqueRange for highlighting textarea when supported #379

Description

@bartveneman

This could be a performance benefit for (for know only) Blink-based browsers that wouldn't need to copy the entire textarea contents into an extra div, sync the changes and perform the highlighting on that element.

See

Example from https://olliewilliams.xyz/blog/opaquerange/:

const input = document.querySelector('input[type="text"]');
const startIndex = input.value.indexOf("example");
const myOpaqueRange = input.createValueRange(startIndex, startIndex + "example".length);
const greenHighlights = new Highlight(myOpaqueRange);
CSS.highlights.set("green", greenHighlights);

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

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions