Can't set animation using ::part() from outside of component's shadow DOM
Categories
(Core :: CSS Transitions and Animations, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox119 | --- | fixed |
People
(Reporter: mstriemer, Assigned: emilio)
Details
Attachments
(1 file)
When using components with Shadow DOM you may end up with a parent component wanting to modify a child component's styles, using ::part(name)
.
This however does not work when setting an animation, since the @keyframes
for the animation can't be passed into the shadow DOM of the child component.
In this example there should be a green box that spins, but it doesn't spin. Moving @keyframes
to display-el
makes it start spinning.
I don't know if this is supposed to work, but it seems like something that should be possible to do without modifying display-el
.
// https://jsbin.com/didaladupi/edit?html,js,output
class WrapperEl extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<style>
@keyframes spin {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
display-el::part(icon) {
animation: spin 1s linear infinite;
background: green;
}
</style>
<display-el></display-el>
`;
}
}
customElements.define("wrapper-el", WrapperEl);
class DisplayEl extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<style>
div {
width: 16px; height: 16px; background: red;
}
</style>
<p><div part="icon"></div> Some text</p>
`;
}
}
customElements.define("display-el", DisplayEl);
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
This is mostly what we were doing, except this handles ::part()
correctly.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 3•1 year ago
|
||
Backed out for causing wpt failures on keyframes-004.html.
This failed on multiple platforms. So far, it failed on linux, osx and android.
[task 2023-09-16T01:43:28.074Z] 01:43:28 INFO - TEST-START | /css/css-scoping/keyframes-004.html
[task 2023-09-16T01:43:28.084Z] 01:43:28 INFO - Closing window 9cf0bd54-1d4f-499c-8e40-84dd9c7c74b2
[task 2023-09-16T01:43:28.243Z] 01:43:28 INFO -
[task 2023-09-16T01:43:28.243Z] 01:43:28 INFO - TEST-UNEXPECTED-PASS | /css/css-scoping/keyframes-004.html | @keyframes in shadow tree applies to the slotted element - expected FAIL
[task 2023-09-16T01:43:28.243Z] 01:43:28 INFO - TEST-INFO | expected FAIL
[task 2023-09-16T01:43:28.243Z] 01:43:28 INFO - TEST-OK | /css/css-scoping/keyframes-004.html | took 170ms
[task 2023-09-16T01:43:28.245Z] 01:43:28 INFO - PID 30214 | 1694828608245 Marionette INFO Stopped listening on port 55267
[task 2023-09-16T01:43:28.679Z] 01:43:28 INFO - PID 30214 | console.error: ({})
[task 2023-09-16T01:43:28.842Z] 01:43:28 INFO - Browser exited with return code 0
[task 2023-09-16T01:43:28.843Z] 01:43:28 INFO - Closing logging queue
[task 2023-09-16T01:43:28.843Z] 01:43:28 INFO - queue closed
[task 2023-09-16T01:43:28.856Z] 01:43:28 INFO - Application command: /builds/worker/workspace/build/application/firefox/firefox --marionette about:blank -profile /tmp/tmp4juae5t5
[task 2023-09-16T01:43:28.867Z] 01:43:28 INFO - Starting runner
[task 2023-09-16T01:43:29.462Z] 01:43:29 INFO - PID 30580 | ATTENTION: default value of option mesa_glthread overridden by environment.
[task 2023-09-16T01:43:29.476Z] 01:43:29 INFO - PID 30580 | 1694828609475 Marionette INFO Marionette enabled
[task 2023-09-16T01:43:29.530Z] 01:43:29 INFO - PID 30580 | ATTENTION: default value of option mesa_glthread overridden by environment.
[task 2023-09-16T01:43:29.547Z] 01:43:29 INFO - PID 30580 | 1694828609547 Marionette INFO Listening on port 42680
[task 2023-09-16T01:43:29.803Z] 01:43:29 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:31.011Z] 01:43:31 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:32.600Z] 01:43:32 INFO - PID 30580 | console.error: ({})
[task 2023-09-16T01:43:33.739Z] 01:43:33 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:33.741Z] 01:43:33 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:33.741Z] 01:43:33 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:33.741Z] 01:43:33 INFO - PID 30580 | console.error: (new Error("Unexpected content-type \"text/plain;charset=US-ASCII\"", "resource://services-settings/Utils.sys.mjs", 399))
[task 2023-09-16T01:43:33.943Z] 01:43:33 INFO - TEST-START | /css/css-scoping/keyframes-005.html
Assignee | ||
Updated•1 year ago
|
Comment 5•1 year ago
|
||
bugherder |
Description
•