mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
More detach shadow changes
This commit is contained in:
parent
d4be72d386
commit
ef02196dd8
5 changed files with 32 additions and 9 deletions
|
@ -74,11 +74,22 @@
|
|||
|
||||
class MediaControls {
|
||||
constructor() {
|
||||
this.nonce = Date.now();
|
||||
// Get the instance of the shadow root where these controls live.
|
||||
this.controls = document.servoGetMediaControls("@@@id@@@");
|
||||
// Get the instance of the host of these controls.
|
||||
this.media = this.controls.host;
|
||||
|
||||
this.shutthingDown = false;
|
||||
this.mutationObserver = new MutationObserver(() => {
|
||||
// We can only get here if the `controls` attribute is removed.
|
||||
this.shutthingDown = true;
|
||||
this.mutationObserver.disconnect();
|
||||
});
|
||||
this.mutationObserver.observe(this.media, {
|
||||
attributeFilter: ["controls"]
|
||||
});
|
||||
|
||||
// Create root element and load markup.
|
||||
this.root = document.createElement("div");
|
||||
this.root.classList.add("root");
|
||||
|
@ -203,6 +214,9 @@
|
|||
}
|
||||
|
||||
render(from = this.state) {
|
||||
if (this.shutthingDown) {
|
||||
return;
|
||||
}
|
||||
const isAudioOnly = this.media.localName == "audio";
|
||||
if (!isAudioOnly) {
|
||||
// XXX This should ideally use clientHeight/clientWidth,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue