Skip to content

[selectors-4] :defined #2258

Closed
Closed

Description

@annevk

HTML defines :defined: https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined.

  1. Is that enough for a definition of a new pseudo-class?
  2. Is it fine for HTML to define this?
  3. Should Selectors contain a registry of externally defined selectors?

(I'm asking this in part since we're considering a :heading(level) pseudo-class.)

See also: WICG/webcomponents#665.

cc @domenic @snuggs

Activity

  1. fantasai commented on Feb 2, 2018

    @fantasai
    Collaborator

    Can I get a layperson's definition of :defined and what it's used for? :)

    Wrt :heading(), we've gotten requests for this an declined them so far. If it's something we want to add, we can add it to Selectors--it's definitely not an HTML-specific concept, so it should go into Selectors and not HTML.

  2. annevk commented on Feb 3, 2018

    @annevk
    MemberAuthor

    :defined matches all elements that had no problem during construction, roughly. It's useful since you can now implement your own element class and sometimes you want to match elements for which the constructor has not yet run (or vice versa).

    As for headings, that sounds reasonable, though we'll run into the data model issue again (though arguably we do already for other things, so it doesn't necessarily add to the problem).

  3. snuggs commented on Mar 15, 2018

    @snuggs

    To embellish on @annevk's statement with an example.

    <style>
      foo-bar { visibility: hidden }
      foo-bar:defined { visibility: show }
    </style>
    
    <foo-bar>You can't see me...yet</foo-bar>

    If a user wanted to preserve real estate but not display until element is defined.

    @annevk does this help or hurt?

  4. css-meeting-bot commented on Nov 21, 2018

    @css-meeting-bot
    Member

    The CSS Working Group just discussed :defined, and agreed to the following:

    • RESOLVED: Add :defined to selectors L4
    The full IRC log of that discussion <dael> Topic: :defined
    <dael> github: https://github.com//issues/2258
    <dael> fantasai: HTML defines :defined pseudo class in its spec, in general we define in selectors and HTML refines. So should :defined be defined in selectors?
    <dael> fantasai: Matches all elements that had no problem during constructions
    <dael> Rossen: Any reason why it shouldn't be defined in selectors?
    <dael> fantasai: Very HTML specific currently. That's the only reason I can think of
    <dael> Rossen: Not crazy about the name, it's a little too generic
    <dael> florian: Would fail to match on custom elements not defined properly and any element whose semantics are unknown to browser?
    <dael> fantasai: Don't know
    <dael> florian: Reading example that seems to be the case. If using on a not known element it won't match.
    <dael> florian: Does make it non-HTML specific even if use cases are HTML specific
    <dael> florian: Seems like we should do this, but also study more
    <dael> fantasai: It's impl afaict
    <dael> Rossen: Impl in blink?
    <dael> fantasai: Not registering as invalid in test case.
    <dael> emilio: Impl in blink, gecko, and webkit
    <fantasai> http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cstyle%3E%0Ahtml%3Adefined%2C%20foo%3Adefined%20%7B%20border%3A%20solid%20green%3B%20%7D%0A%3C%2Fstyle%3E%0A%3Cfoo%3EThis%20is%20a%20test%3C%2Ffoo%3E
    <tantek> are there tests for this?
    <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
  5. added a commit that references this issue on Nov 22, 2018
  6. snuggs commented on Dec 13, 2018

    @snuggs

    @annevk @fantasai is this good to close now that is on track with CSS Level4?

  7. annevk commented on Dec 13, 2018

    @annevk
    MemberAuthor

    I think it would make sense to close this when the PR that adds this to Selectors Level 4 lands.

  8. 2 remaining items

  9. added a commit that references this issue on Oct 24, 2019
  10. hober commented on Apr 21, 2021

    @hober
    Member

    I think it would make sense to close this when the PR that adds this to Selectors Level 4 lands.

    As #3735 landed a while ago, can we close this issue now?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions