Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[selectors-4] Add :defined pseudo-class #3735

Merged
merged 5 commits into from
Feb 8, 2020
Merged

Conversation

spectranaut
Copy link
Contributor

@spectranaut spectranaut commented Mar 15, 2019

[selectors-4] Add the :defined pseudo-class as discussed in #2258.

The original definition has been moved verbatim from the html spec and a note and examples added. PR to remove the definition from the html spec from WHATWG.

A test for this definition has previously been submitted: ewilligers/web-platform-tests@92a561a

Worked on with @zcorpan and @isaacdurazo.

isaacdurazo added a commit to bocoup/html that referenced this pull request Mar 15, 2019
Since the CSS Working Group has discussed and decided[1] to add the :defined pseudo-class to their spec under Selectors L4 and a pull request has been submitted with this change[2], we can remove it from here.

[1] w3c/csswg-drafts#2258
[2] w3c/csswg-drafts#3735
isaacdurazo added a commit to bocoup/html that referenced this pull request Mar 15, 2019
Since the CSS Working Group has discussed and decided[1] to add the :defined pseudo-class to their spec under Selectors L4 and a pull request has been submitted with this change[2], we can remove it from here.

[1] w3c/csswg-drafts#2258
[2] w3c/csswg-drafts#3735
@zcorpan zcorpan requested review from annevk and fantasai March 18, 2019 15:55
@annevk
Copy link
Member

annevk commented Mar 18, 2019

See my comments at whatwg/html#4433 (comment). I don't think a change to how we do layering between CSS and HTML has been discussed so this specification should probably define this header more abstractly while leaving the actual matching requirements for DOM/HTML to HTML.

selectors-4/Overview.bs Outdated Show resolved Hide resolved
@zcorpan
Copy link
Member

zcorpan commented Mar 18, 2019

@annevk ok. Per the meeting discussion in #2258 (comment)

<dael> Rossen: If this has impl in various UA and since it's a selector makes sense as part of selectors unless we're against it in the way it's defined. We should accept it and refine
<dael> florian: Sounds good
<dael> Rossen: Other comments or Objections to adding :defined to selectors L4?
<dael> RESOLVED: Add :defined to selectors L4

As I understand this, the WG resolved to take the spec as-is (for now). cc @atanassov

Do we want this to follow the model of e.g. :link instead?

@annevk
Copy link
Member

annevk commented Mar 18, 2019

I think either Selectors embraces DOM/HTML and is defined on top of that data model or it keeps things abstract (which is shaky btw, there's some open issues around that) as it tries to do today. Doing both is too confusing though.

@fantasai
Copy link
Collaborator

I agree with @annevk and I believe the resolution was to add it at the same level of definition as e.g. :link etc, as he expects.

Copy link
Collaborator

@fantasai fantasai left a comment

Choose a reason for hiding this comment

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

[Marking needs work per @annevk's comments.]

zcorpan pushed a commit to bocoup/html that referenced this pull request Oct 24, 2019
Since the CSS Working Group has discussed and decided[1] to add the :defined pseudo-class to their spec under Selectors L4 and a pull request has been submitted with this change[2], we can remove it from here.

[1] w3c/csswg-drafts#2258
[2] w3c/csswg-drafts#3735
@zcorpan
Copy link
Member

zcorpan commented Oct 24, 2019

I've changed this so that it has a high-level definition in Selectors, and has the examples be specific for HTML.

@zcorpan zcorpan requested a review from fantasai October 24, 2019 10:06
@zcorpan
Copy link
Member

zcorpan commented Oct 24, 2019

There are some tests in wpt for :defined already:

$ git grep ":defined"
css/selectors/invalidation/defined.html:    <title>CSS Selectors Invalidation: :defined</title>
css/selectors/invalidation/defined.html:    <meta name="assert" content="This tests that the :defined selector is effective">
css/selectors/invalidation/defined.html:      #a1:defined {
css/selectors/invalidation/defined.html:      :defined + #b1 {
css/selectors/invalidation/defined.html:      :defined > #c1 {
css/selectors/invalidation/defined.html:      div + :defined + * #d1 {
css/selectors/invalidation/defined.html:      }, ":defined selector is effective");
custom-elements/Document-createElement.html:    assert_false(instance2.matches(':defined'));
custom-elements/pseudo-class-defined.html:  :defined { color:${defined}; }
custom-elements/pseudo-class-defined.html:  :not(:defined) { color:${not_defined}; }
custom-elements/pseudo-class-defined.html:  // Test ":defined" changes when the custom element was defined.
custom-elements/pseudo-class-defined.html:    assert_equals(element.matches(':defined'), expected, 'matches(":defined")');
custom-elements/pseudo-class-defined.html:    assert_equals(element.matches(':not(:defined)'), !expected, 'matches(":not(:defined")');
custom-elements/pseudo-class-defined.html:  }, `${description} should ${expected ? 'be' : 'not be'} :defined`);

@zcorpan
Copy link
Member

zcorpan commented Feb 3, 2020

Ping @fantasai @tabatkins :)

@tabatkins
Copy link
Member

Ah sorry for the delay.

Hmm. Overall this is fine, but now it sounds really abstract, to the point that I don't think I could figure out what it meant if I didn't already know about custom elements and their definitions.

I'll do a little tweaking and then accept it.

@tabatkins tabatkins merged commit 63b4180 into w3c:master Feb 8, 2020
@zcorpan
Copy link
Member

zcorpan commented Feb 10, 2020

Thanks @tabatkins!

@bkardell
Copy link
Contributor

If we get to more than just a single global registry, does this still hold up?

@zcorpan
Copy link
Member

zcorpan commented Feb 10, 2020

@bkardell this says it's up to the host language to say what matches :defined. For HTML this is https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined - that could be changed in HTML, and SVG could say something else, without needing updates to the Selectors spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selectors-4 Current Work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants