Skip to content
Snippets Groups Projects
Commit d19982b7 authored by qsm-odoo's avatar qsm-odoo
Browse files

[FIX] web, web_editor: improve browser support for JS lazy loading


opw-2125858

closes odoo/odoo#41362

Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
parent 56cfd344
No related branches found
No related tags found
Loading
......@@ -21,11 +21,13 @@ function waitLazy() {
}
waitingLazy = true;
document.querySelectorAll('.o_wait_lazy_js').forEach(function (element) {
var lazyEls = document.querySelectorAll('.o_wait_lazy_js');
for (var i = 0; i < lazyEls.length; i++) {
var element = lazyEls[i];
blockEvents.forEach(function (evType) {
element.addEventListener(evType, blockFunction);
});
});
}
}
/**
* Unblocks the DOM sections blocked by @see waitLazy and removes the related
......@@ -37,12 +39,14 @@ function stopWaitingLazy() {
}
waitingLazy = false;
document.querySelectorAll('.o_wait_lazy_js').forEach(function (element) {
var lazyEls = document.querySelectorAll('.o_wait_lazy_js');
for (var i = 0; i < lazyEls.length; i++) {
var element = lazyEls[i];
blockEvents.forEach(function (evType) {
element.removeEventListener(evType, blockFunction);
});
element.classList.remove('o_wait_lazy_js');
});
}
}
// Start waiting for lazy loading as soon as the DOM is available
......
......@@ -10,7 +10,10 @@
*/
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('textarea.o_wysiwyg_loader').forEach(textarea => {
// Standard loop for better browser support
var textareaEls = document.querySelectorAll('textarea.o_wysiwyg_loader');
for (var i = 0; i < textareaEls.length; i++) {
var textarea = textareaEls[i];
var wrapper = document.createElement('div');
wrapper.classList.add('position-relative', 'o_wysiwyg_wrapper');
......@@ -24,7 +27,7 @@ document.addEventListener('DOMContentLoaded', () => {
textarea.parentNode.insertBefore(wrapper, textarea);
wrapper.insertBefore(textarea, loadingElement);
});
}
});
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment