w3ctag / design-principles

A small-but-growing set of design principles collected by the TAG while reviewing specifications
https://w3ctag.github.io/design-principles
162 stars 44 forks source link

Web platform features that augment HTML elements en masse #423

Open LeaVerou opened 1 year ago

LeaVerou commented 1 year ago

This came up in the design review of Speculation Rules. In a nutshell, these are rules that add pre-fetching and pre-rendering to certain links that match a set of criteria (selectors and URL patterns for their href).

Since there is no precedent, the API designers had to invent their own querying syntax, based on JSON. In our discussion, we realized that the only precedent in the Web Platform for this sort of thing (rules for sets of HTML elements specified elsewhere) is ...CSS. However, it is questionable whether such a thing is presentational, and even if this one is, others are not.

Indeed, there have been several proposals over the years for CSS-like syntax for non-presentational things:

I think we should have a unified position on these things.

annevk commented 1 year ago

I'm not sure exactly what the ask is here, but Media Queries and Selectors are considered standalone concepts from CSS precisely so they can be used in other contexts. (They do end up sharing a lot of parser logic with CSS.)

jeremyroman commented 1 year ago

In fact our proposal does leverage CSS selectors for that precise reason (it's wonderful that CSS selectors can be reused for the capabilities they have), but couldn't find an elegant way for it to solve all of our cases.