w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 661 forks source link

[resize-observer] "Calculate depth for node" is unclear #3840

Open smaug---- opened 5 years ago

smaug---- commented 5 years ago

https://drafts.csswg.org/resize-observer/#calculate-depth-for-node-h doesn't explain what parent-traversal path means. Does it include Shadow DOM? In which way? Is ShadowRoot included?

emilio commented 5 years ago

FWIW in Chromium it doesn't seem to include shadow DOM. But that may be an oversight?

https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/resize_observer/resize_observation.cc?l=32&rcl=22be1c05550aaa7f597f0cee5174500fd36588da

cc @atotic

gregwhitworth commented 5 years ago

Hmmm, that's a good question. I can't think of why shadow DOM shouldn't be included. I think it makes sense only if the shadow DOM has a mode of open though. @smaug---- @atotic @tabatkins any thoughts?

emilio commented 5 years ago

Why only open shadow trees? That doesn't make much sense to me. We should probably either use the flat tree depth, or the depth using "either parentNode or host if I'm a shadow root" (not sure the spec concept for that).

atotic commented 5 years ago

We should specify how to calculate depth with Shadow DOM. Would replacing

Let p be the parent-traversal path from node to a root Element of this element’s DOM tree.

with

Let p be the parent-traversal path from node to a root Element of this element’s flattened DOM tree.

work?

BorisChiou commented 5 years ago

Let p be the parent-traversal path from node to a root Element of this element’s flattened DOM tree.

This looks ok to me. Actually, Firefox uses this way (I.e. calculates the depth by traversing the element’s flattened DOM tree) right now.

smaug---- commented 5 years ago

'parent-traversal path' isn't defined.