Closed Bug 992245 Opened 10 years ago Closed 6 years ago

[WebComponents] Implement :host pseudo class


(Core :: DOM: Core & HTML, defect, P2)




Tracking Status
firefox61 --- fixed


(Reporter: vingtetun, Assigned: emilio)


(Blocks 1 open bug, )


(Keywords: dev-doc-complete)


(4 files)

Just looking at some tutos in both Chrome and Firefox and it seems like the :host rule demo at does not work as expected in Firefox.

(This is with dom.webcomponents.enabled = true).
I'm mostly concerned about the ability to react to user states. Fwiw the first demo seems to not work in Firefox, while the second demo (related to handling user state, does not seems to work in both Firefox nor Chrome 35 on my laptop)
Summary: [WebComponents] :host rule does not seems to work in → [WebComponents] Implement :host pseudo class
Attached patch testsSplinter Review
These patch builds on top of things in bug 1082060, so that bug needs to be sorted out first.
Do we still need this with Shadow DOM v1?
Assignee: wchen → nobody
Priority: -- → P3
Hi Ben, would you please confirm comment 6?
Flags: needinfo?(btian)
Flags: needinfo?(btian)
(In reply to Andrew Overholt [:overholt] from comment #6)
> Do we still need this with Shadow DOM v1?

Yes we still need this per
Priority: P3 → P2
No longer blocks: shadowdom-initial-release
This selector is not as gross as :host-context, I think (i.e., it's doable to make it fast), but I think there are spec issues to sort out. Not that they necessarily block the implementation I guess, but worth taking them into account... is broken with Shadow DOM because of this. At least we should implement the selector-less variant. seems another broken page due to this.
I added some infra for this in Will finish this up. I'll add support for the functional version of it in a followup bug.
Assignee: nobody → emilio
here's a basically untested try run:

I only checked that this fixed the size of the icons in the footer of with the shadow DOM pref enabled.

Need to check cascade order and such.
It also seems to fix the XFinity stuff.
Comment on attachment 8966020 [details]
Bug 992245: Implement the non-functional :host selector.

::: commit-message-efc15:6
(Diff revision 3)
> +I didn't use the non_ts_pseudo_class_list bits because as soon as we implement
> +the :host(..) bits we're going to need to special-case it anyway.

Actually, I have a feeling that `:host` should probably be handled as a tree-structure pseudo-class in selector crate instead.

::: servo/components/style/
(Diff revision 3)
> +    /// Also, note that other engines don't accept stuff like :host::before /
> +    /// :host::after, so we don't need to store pseudo rules at all.

Does the spec say so? If not, probably worth a spec issue to make it clear one way or the other and have tests for it?

::: testing/web-platform/tests/css/css-scoping/host-cssom-001.html:2
(Diff revision 3)
> +<!doctype html>
> +<title>CSS Test: :host in CSSOM</title>

Methods like matches, querySelector, etc. are defined in DOM standard. They are not part of CSSOM.

CSSOM is for operating CSS, while these methods are getting elements, so they shouldn't be considered CSSOM.

You probably should rename this test.

::: testing/web-platform/tests/css/css-scoping/host-descendant-invalidation.html:2
(Diff revision 3)
> +<!doctype html>
> +<title>CSS Test: :host is accounted for during invalidation</title>

"invalidation" is not something related to the spec... Maybe some title like "element style is correctly updated for rule with :host" is better for a wpt.
Attachment #8966020 - Flags: review?(xidorn+moz) → review+
Pushed by
Tests for non-functional :host selector. r=xidorn
Blocks: 1452640
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Created web-platform-tests PR for changes under testing/web-platform/tests
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #11)
> seems another broken page due to this.

FWIW, this is the only case that these patches didn't fix, and it was because of broken feature detection in their side. As soon as I removed Element.createShadowRoot in this started working.
BCD was already updated; updated Firefox 61 for developers as well.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.