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

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

Closed
emilio opened this issue Nov 9, 2017 · 9 comments

Comments

@emilio
Copy link
Collaborator

emilio commented Nov 9, 2017

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.

@emilio
Copy link
Collaborator Author

emilio commented Nov 9, 2017

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).

@emilio emilio 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? Nov 9, 2017
@fantasai fantasai added cssom-1 Current Work css-cascade-3 css-scoping-1 Current Work labels Dec 4, 2017
@FremyCompany
Copy link
Contributor

Merging with #1548

@emilio
Copy link
Collaborator Author

emilio commented Feb 6, 2018

@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!

@FremyCompany
Copy link
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.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Feb 8, 2018

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.

@css-meeting-bot
Copy link
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

tabatkins added a commit that referenced this issue Jan 13, 2021
…the flat tree do not have any CSS values at all. #1964 #1548
@tabatkins
Copy link
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?

@fantasai
Copy link
Collaborator

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

@emilio
Copy link
Collaborator Author

emilio commented Mar 12, 2021

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
Projects
None yet
Development

No branches or pull requests

8 participants