Workaround for Chromium
This commit is contained in:
+14
-19
@@ -1,25 +1,20 @@
|
|||||||
function xmr_media_lazyload_add_handler(element) {
|
async function xmr_media_lazyload_perform(element) {
|
||||||
element.addEventListener('play', (event) => {
|
let content = element.querySelector("noscript");
|
||||||
let content = element.querySelector("noscript");
|
if (content) {
|
||||||
if (content) {
|
element.innerHTML = content.innerText;
|
||||||
element.innerHTML = content.innerHTML;
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function xmr_media_lazyload_initialize() {
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
// Figure out what to load.
|
|
||||||
let elements = document.querySelectorAll(".block-media > [data-lazyload]");
|
|
||||||
let stack = Array.from(elements);
|
|
||||||
console.debug("Lazily loading " + stack.length + " elements...");
|
|
||||||
|
|
||||||
// Add a lazyloading handler to all entries.
|
async function xmr_media_lazyload_initialize() {
|
||||||
for (let el of stack) {
|
// Figure out what to load.
|
||||||
xmr_media_lazyload_add_handler(el);
|
let elements = document.querySelectorAll(".block-media > [data-lazyload]");
|
||||||
}
|
let stack = Array.from(elements);
|
||||||
|
console.debug("Lazily loading " + stack.length + " elements...");
|
||||||
|
|
||||||
resolve();
|
// Add a lazyloading handler to all entries.
|
||||||
});
|
for (let el of stack) {
|
||||||
|
xmr_media_lazyload_perform(el);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user