Skip to content

Add .pseudoTarget property to selected event types#413

Open
danielsakhapov wants to merge 14 commits intow3c:mainfrom
danielsakhapov:spec_edit_for_css_12163
Open

Add .pseudoTarget property to selected event types#413
danielsakhapov wants to merge 14 commits intow3c:mainfrom
danielsakhapov:spec_edit_for_css_12163

Conversation

@danielsakhapov
Copy link

As resolved in w3c/csswg-drafts#12163, add .pseudoTarget property to selected event types and describe the initialization process for it.

@danielsakhapov
Copy link
Author

@garykac could you ptal?

@danielsakhapov danielsakhapov requested a review from dbaron February 3, 2026 19:46
@danielsakhapov danielsakhapov requested a review from dbaron February 5, 2026 11:35

<p class="note">
This {{CSSPseudoElement}} must be the same object instance that would be returned
by calling <code>.pseudo(type)</code> on the |pseudoElement|'s originating element
Copy link

@smaug---- smaug---- Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is .pseudo(type) ?
I guess this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this part to include links

Copy link

@smaug---- smaug---- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to handle event dispatch in Shadow DOM. We don't want to leak pseudo element usage in shadow DOM to light DOM.

@danielsakhapov
Copy link
Author

This doesn't seem to handle event dispatch in Shadow DOM. We don't want to leak pseudo element usage in shadow DOM to light DOM.

Not entirely sure how to phrase that, ptal!


1. Let |ultimateOriginatingElement| be the |pseudoElement|'s [=ultimate originating element=].

1. If |ultimateOriginatingElement| is in a shadow tree (that is, its [=tree/root=] is a {{ShadowRoot}}) and |eventTarget| is not contained within the same shadow tree, then exit.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect that "ultimateOriginatingElement" (maybe we can find some other name for that ;) ) would be compared to the currentTarget and then the getter of pseudoElement would either return the object or null. Something similar-ish to https://html.spec.whatwg.org/#dom-commandevent-source perhaps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@smaug----
Copy link

Just FYI, there is now a rather major refactoring happening to UI Events spec, so this one might need to wait until w3c/pointerevents#564 and related PRs are done. Those should happen real soon.

@danielsakhapov
Copy link
Author

Just FYI, there is now a rather major refactoring happening to UI Events spec, so this one might need to wait until w3c/pointerevents#564 and related PRs are done. Those should happen real soon.

I see, thanks for the heads up!

Does this PR look good now btw?

1. If {{UIEvent/pseudoTarget}} internal slot is <code>null</code>, then return <code>null</code>.
1. Let |currentTarget| be {{Event/currentTarget}}.
1. If |currentTarget| is <code>null</code>, then return <code>null</code>.
1. Let |origin| be {{Event/target}} (which would be {{UIEvent/pseudoTarget}}'s [=ultimate originating element=]).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ultimate originating element" sounds a bit, hmm, comical :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true... but since there can be nested pseudo-elements, the originating element can be also pseudo-element, so ultimate originating element is Element... that's an established CSS term! :)

@danielsakhapov danielsakhapov force-pushed the spec_edit_for_css_12163 branch from e0b6dac to c4c7e79 Compare February 24, 2026 13:44
@danielsakhapov
Copy link
Author

The blocking PR has been merged now it seems, ptal

Copy link
Member

@dbaron dbaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, although I think @smaug----'s review is more important here.

This {{CSSPseudoElement}} must be the same object instance that would be returned
by calling {{Element/pseudo(type)}} if the |pseudoElement|'s [=originating element=] is an {{Element}},
or {{CSSPseudoElement/pseudo(type)}} of {{CSSPseudoElement}} representing |pseudoElement|'s [=originating element=] otherwise.
This is necessary, to ensure that |pseudoInstance| is a canonical object representing |pseudoElement|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is necessary, to ensure that |pseudoInstance| is a canonical object representing |pseudoElement|.
This is necessary to ensure that |pseudoInstance| is the canonical object representing |pseudoElement|.

No comma here, and the rather than a. (The use of a comma in this case makes the writing sound to me like English written by a native German speaker. It may apply to other languages too. :-) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants