owl icon indicating copy to clipboard operation
owl copied to clipboard

Extention: function loadCSS in owl/src/utils.ts

Open renlite opened this issue 5 years ago • 1 comments

Extention of owl/src/utils.ts with function loadCSS (like loadJS)

JavaScript

const loadedStyles = {};

export function loadCSS(url) {
    if (url in loadedStyles) {
        return loadedStyles[url];
    }
    const promise = new Promise((resolve, reject) => {
        let link = document.createElement('link');
        link.type = 'text/css';
        link.rel = 'stylesheet';
        link.onload = () => { resolve(); console.log('style loaded'); };
        link.href = url;
        let headScript = document.querySelector('script');
        headScript.parentNode.insertBefore(link, headScript);
    });
    loadedStyles[url] = promise;
    return promise;
}

renlite avatar Dec 01 '20 08:12 renlite

seems like a very good idea... :+1:

ged-odoo avatar Dec 01 '20 10:12 ged-odoo