Bug 210249 - [CSS Shadow Parts] Bad style sharing between sibling elements with different part attributes
Summary: [CSS Shadow Parts] Bad style sharing between sibling elements with different ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 148695
  Show dependency treegraph
 
Reported: 2020-04-08 23:24 PDT by Justin Fagnani
Modified: 2020-07-03 03:27 PDT (History)
6 users (show)

See Also:


Attachments
patch (4.12 KB, patch)
2020-04-10 07:14 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (4.08 KB, patch)
2020-04-10 07:54 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Fagnani 2020-04-08 23:24:22 PDT
The ::part() selector released in 13.1, and as currently implemented in TP and nightly, is selecting the wrong elements when parts are nested in any container element in a shadow root.

Given this DOM:

<!-- This div is necessary to trigger the bug -->
<div>
  <span part="one">Should be Blue</span> | 
  <span part="two">Should be Red</span>
</div>

And these selectors:

my-element::part(one) {
  color: blue;
}
my-element::part(two) {
  color: red;
}

The text spans should be blue then red as described. Instead they are both blue.

If the <div> is removed, or if the second <span> is changed to a different tag, the colors are correct.

JS Bin: https://jsbin.com/bucejul/3/edit
Comment 1 Serhii Kulykov 2020-04-09 00:31:04 PDT
Setting style attribute, e.g. display, or direction attribute on part="two", also forces the red color to apply.
Comment 2 Radar WebKit Bug Importer 2020-04-09 16:10:25 PDT
<rdar://problem/61547528>
Comment 3 Emilio Cobos Álvarez (:emilio) 2020-04-10 06:15:22 PDT
That smells a lot like broken style sharing.

Firefox had a somewhat similar bug in fact: https://bugzilla.mozilla.org/show_bug.cgi?id=1604989
Comment 4 Antti Koivisto 2020-04-10 06:46:26 PDT
Yeah, bet that's the problem. Those spans are obvious style sharing candidates if you forget about 'part'.
Comment 5 Antti Koivisto 2020-04-10 07:14:40 PDT
Created attachment 396079 [details]
patch
Comment 6 Antti Koivisto 2020-04-10 07:54:24 PDT
Created attachment 396082 [details]
patch
Comment 7 Daniel Bates 2020-04-10 07:57:00 PDT
Comment on attachment 396082 [details]
patch

Make sense to me,
Comment 8 EWS 2020-04-10 09:13:47 PDT
Committed r259877: <https://trac.webkit.org/changeset/259877>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396082 [details].
Comment 9 Justin Fagnani 2020-04-10 10:33:25 PDT
Thanks for the really quick turnaround!
Comment 10 Justin Fagnani 2020-04-10 10:48:56 PDT
A question about the release process for bug fixes like this: will this go out in a patch release on 13.1, or the next big release? ie, will we have to tell developers to use a ::part() polyfill until 13.2?
Comment 11 Ryosuke Niwa 2020-04-10 11:02:18 PDT
(In reply to Justin Fagnani from comment #10)
> A question about the release process for bug fixes like this: will this go
> out in a patch release on 13.1, or the next big release? ie, will we have to
> tell developers to use a ::part() polyfill until 13.2?

It’s unlikely that a bug fix like this makes it to a software update unless there is a major site that’s been actively affected.
Comment 12 Antti Koivisto 2020-07-03 03:27:11 PDT
FYI, this fix is in the current macOS 10.15.6/iOS 13.6 public beta.