This proposal was inspired by this issue in Editing discussions.
Highlight API allows web developers to style arbitrary range objects without causing DOM updates of the view.
There are a number of scenarios where this would be useful, including third party spellcheck and grammar extensions, javascript implementation of find-on-page, or javascript, rendering of its own selection.
Currently, browsers do not provide this functionality which forces web developers to modify DOM in order to achieve desired effect. This increases complexity and causes unexpected behaviors and site crashes when third party extensions are trying to modify main document’s DOM.
The Highlight API provides a programmatic way of adding and removing highlights that do not affect the underlying DOM structure, but instead applies styles to text based on Range objects.
This feature would be super useful for Javascript frameworks that implement any aforementioned scenarios.
We would love to get thoughts on this from the community on the shape of the API, some open questions and use cases.
Link to the Explainer.