Migrate custom properties from media to parent
This commit is contained in:
parent
145f2ae24f
commit
a9c4e77d1b
@ -269,6 +269,9 @@ class Plyr {
|
|||||||
wrap(this.media, this.elements.container);
|
wrap(this.media, this.elements.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Migrate custom properties from media to container (so they work 😉)
|
||||||
|
ui.migrateStyles.call(this);
|
||||||
|
|
||||||
// Add style hook
|
// Add style hook
|
||||||
ui.addStyleHook.call(this);
|
ui.addStyleHook.call(this);
|
||||||
|
|
||||||
|
20
src/js/ui.js
20
src/js/ui.js
@ -264,6 +264,26 @@ const ui = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Migrate any custom properties from the media to the parent
|
||||||
|
migrateStyles() {
|
||||||
|
// Loop through values (as they are the keys when the object is spread 🤔)
|
||||||
|
Object.values({ ...this.media.style })
|
||||||
|
// We're only fussed about Plyr specific properties
|
||||||
|
.filter(key => key.startsWith('--plyr'))
|
||||||
|
.forEach(key => {
|
||||||
|
// Set on the container
|
||||||
|
this.elements.container.style.setProperty(key, this.media.style.getPropertyValue(key));
|
||||||
|
|
||||||
|
// Clean up from media element
|
||||||
|
this.media.style.removeProperty(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove attribute if empty
|
||||||
|
if (is.empty(this.media.style)) {
|
||||||
|
this.media.removeAttribute('style');
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ui;
|
export default ui;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user