-
Notifications
You must be signed in to change notification settings - Fork 759
Open
Open
[css-pseudo] Add a property to the
CSSPseudoElement IDL interface to retrieve pseudo argument(s)#12161Feature
Copy link
Labels
css-pseudo-4Current WorkCurrent Work
Description
Full context: https://github.com/danielsakhapov/CSSPseudoElementDoc?tab=readme-ov-file#32-parameterized-pseudo-elements
Description:
How to retrieve pseudo argument(s) for e.g. ::part(foo), ::view-transition-group(name), ::slotted(selector)? Should it just be a part of type value or a new attribute e.g. argument should be added?
- Include parameter within the
typeattribute- Pros:
- Requires no changes to the existing interface structure (no new attributes).
- The complete identifier used to retrieve the pseudo element is available.
- Cons:
- Developers would need to manually parse the
typestring to separate the base pseudo element name (e.g.,::part) from its argument (e.g.,foo). - Less structured; mixes the type identifier with its arguments.
- Could become cumbersome if future pseudo elements allow more complex argument syntax (e.g., multiple arguments, different data types).
- Developers would need to manually parse the
- Pros:
- Add a new dedicated attribute (e.g.,
argumentorparameters)- Description: Introduce a new nullable read-only attribute specifically for the parameter(s). This could be a single string (e.g.,
argument: CSSOMString?) or potentially a sequence if multiple parameters were ever supported (e.g.,parameters: sequence<CSSOMString>?). Forelement.pseudo('::part(foo)'), this new attribute would return"foo", while thetypeattribute would likely return just"::part". - Pros:
- Provides clean, structured access to the parameter value(s).
- Separates the core type identifier (
type) from its specific arguments. - More extensible and robust for handling potentially more complex parameterized pseudo elements in the future.
- Easier for developers to work with, avoiding manual string parsing.
- Cons:
- Requires adding a new attribute to the
CSSPseudoElementinterface, increasing its complexity slightly. - Requires defining the behavior for non-parameterized pseudos (e.g., should the attribute be
null, an empty string, or an empty sequence?).
- Requires adding a new attribute to the
- Description: Introduce a new nullable read-only attribute specifically for the parameter(s). This could be a single string (e.g.,
Recommendation:
Add a new dedicated property. Providing direct access to the parameter via a dedicated attribute improves developer ergonomics by avoiding manual string parsing and clearly separates the pseudo element's fundamental type from its specific instance arguments, also it is somewhat future-proof.
Metadata
Metadata
Assignees
Labels
css-pseudo-4Current WorkCurrent Work
Type
Projects
Status
Friday Afternoon