Skip to content

[css-cascade] [css-scoping] [cssom] What should getComputedStyle return for an element which isn't in the flat tree? #1964

Closed

Description

@emilio

I believe implementations now just make it inherit from the default style, but that's not intuitive either, and in any case it's not specced, but should be.

Activity

  1. emilio commented on Nov 9, 2017

    @emilio
    CollaboratorAuthor

    I guess this affects a few more specs.

    CSS Cascade says in https://drafts.csswg.org/css-cascade/#inheriting:

    Inheritance propagates property values from parent elements to their children. The inherited value of a property on an element is the computed value of the property on the element’s parent element. For the root element, which has no parent element, the inherited value is the initial value of the property.

    But there's no mention to the flattened tree anywhere in that spec.

    CSS Scoping says in https://drafts.csswg.org/css-scoping/#shadow-gloss:

    However, the shadow tree, when it exists, is used in the construction of the flattened element tree, which CSS uses for all purposes after Selectors (including inheritance and box construction).

  2. changed the title [-][cssom] What should getComputedStyle return for an element which isn't in the flat tree?[/-] [+][css-cascade] [css-scoping] [cssom] What should getComputedStyle return for an element which isn't in the flat tree?[/+] on Nov 9, 2017
  3. FremyCompany commented on Feb 6, 2018

    @FremyCompany
    Contributor

    Merging with #1548

  4. emilio commented on Feb 6, 2018

    @emilio
    CollaboratorAuthor

    @FremyCompany I think this is not a dupe of that. A detached subree is not the same as an element which is not on the flat tree.

    An element which is part of a document tree but not of the flat tree would be an unassigned child of a shadow host.

    Could you reopen, o clarify in #1548 that this is also going to be addressed in there? (I don't have the permission).

    Thanks!

  5. FremyCompany commented on Feb 8, 2018

    @FremyCompany
    Contributor

    Cross-posting from 1548:

    An element assigned to a slot doesn't inherit from the shadow host, but from the assigned slot. There's no spec that defines that in case it's not assigned to any slot it should inherit from the host, afaict.

    Ah, that should probably be added then; more than likely it's just an oversight. Using their parent's style is the closest approximation of the behavior that would happen whenever it gets slotted, so that looks reasonable to me.

  6. AmeliaBR commented on Feb 8, 2018

    @AmeliaBR
    Contributor

    A comparison could be made to SVG <symbol> and <defs> children, which are never rendered directly. When the element is cloned into a use-element shadow tree, the clone inherits from that context. But the original DOM elements can still have matched & inherited styles (based on its DOM tree parents), even if they are never used because the element isn't rendered. I think all browsers now calculate styles in that case -- although Firefox used to be (maybe still is) buggy, treating them as detached elements.

  7. css-meeting-bot commented on Jul 4, 2018

    @css-meeting-bot
    Member

    The Working Group just discussed What should getComputedStyle return for an element which isn't in the flat tree?.

    The full IRC log of that discussion <florian> topic: What should getComputedStyle return for an element which isn't in the flat tree?
    <florian> github: https://github.com//issues/1964
    <florian> emilio: frremy added that, but we already resolved
    <florian> frremy: it's a bot bug, nothing to talk about
    <emilio> Was resolved on https://github.com//issues/1548#issuecomment-380383455
  8. tabatkins commented on Jan 13, 2021

    @tabatkins
    Member

    Okay, we've added a paragraph to section 4 that should cover this, per the resolution in #1548:

    Elements that are not connected or are not part of the document’s flattened element tree do not participate in CSS value processing, and do not have declared, cascaded, specified, computed, used, or actual values, even if they potentially have style declarations assigned to them (for example, by a style attribute).

    CSSOM still needs to define what should be output by gCS() when an element has no styles; it might already do so but I haven't checked.

    @emilio Can you confirm that this looks correct?

  9. fantasai commented on Jan 13, 2021

    @fantasai
    Collaborator

    Also pls edit cssom since you are the editor. :P

  10. emilio commented on Mar 12, 2021

    @emilio
    CollaboratorAuthor

    Yeah that sounds good, thanks. https://drafts.csswg.org/cssom-1/#extensions-to-the-window-interface should already be doing the right thing.

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