#584: CSS Custom Highlight API Module Level 1

Visit on Github.

Opened Dec 8, 2020

你好 TAG! 吃饭了吗?

I'm requesting a TAG review of CSS Custom Highlight API Module Level 1, which was recently published as a FPWD.

The Custom Highlight API extends the concept of highlight pseudo-elements (see CSS Pseudo-Elements 4 §3 Highlight Pseudo-elements) by providing a way for web developers to style the text of arbitrary Range objects, rather than being limited to the user agent defined ::selection, ::spelling-error, and ::grammar-error. This is useful in a variety of scenarios, including editing frameworks that wish to implement their own selection, find-on-page over virtualized documents, multiple selection to represent online collaboration, or spellchecking frameworks. The Custom 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, accessed via the ::highlight() pseudo element.

Further details:

  • I have reviewed the TAG's API Design Principles
  • Relevant time constraints or deadlines: Nothing in particular
  • The group where the work on this specification is currently being done: CSSWG
  • The group where standardization of this work is intended to be done (if current group is a community group or other incubation venue): CSSWG
  • Major unresolved issues with or opposition to this specification: No known opposition, event part still missing
  • This work is being funded by: Bloomberg, Microsoft, Apple

We'd prefer the TAG provide feedback as 🐛 open issues in our GitHub repo for each point of feedback

Discussions

Discussed Jan 1, 2021 (See Github)
  • We talked about the suitability of using this API for syntax highlighting
  • Why is HighlightsRegister setlike and not maplike? Poor developer experience if one needs to iterate over it to see if an existing Highlight with the same name is registered
Comment by @LeaVerou Jan 11, 2021 (See Github)

To everyone else reviewing: The differences between the explainer and the actual spec are at this point very substantial. I would suggest that people review the spec's own intro section instead of the explainer to get an overview of the current status.

Yes, it is mentioned above in passing, but thought I'd highlight it (pun intended 😁) in case others also start from the explainer by force of habit despite @frivoal's comment, and then realize that all their comments do not apply to the current spec anymore.

Comment by @florian Jan 12, 2021 (See Github)

Lea, I'm pretty sure you meant to @ mention some other Florian.

Comment by @LeaVerou Jan 26, 2021 (See Github)

@hober and I discussed this today in our VF2F. We noticed that HighlightsRegister is a setlike, but throws when a Highlight object with an existing registered name, which indicates that perhaps maplike would have been more appropriate? It's not ideal developer experience if developers need to iterate the entire data structure before registering their object, to check if an existing one of the same name exists. Maplike would also provide an easy way to get all ranges under a given name.

Comment by @frivoal Jan 31, 2021 (See Github)

Filed the above comment as https://github.com/w3c/csswg-drafts/issues/5910

Discussed Mar 15, 2021 (See Github)

Bumped waiting for feedback from CSSW

Discussed May 1, 2021 (See Github)

Issue fixed, review closed!

Comment by @LeaVerou May 11, 2021 (See Github)

@hober and I discussed this in a VF2F breakout today. We noticed that the issue we pointed out in our earlier review has now been fixed, so we're happy with its current state and will go ahead and close this. Feel free to open another review if there are substantial changes in the future.