UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

35 lines 1.67 kB
export function runCssVersionMismatchWarning() { try { if (typeof document !== 'undefined' && process.env.NODE_ENV === 'development') { const runCheck = () => { var _window$Eufemia; const jsVersion = (_window$Eufemia = window.Eufemia) === null || _window$Eufemia === void 0 ? void 0 : _window$Eufemia.version; if (jsVersion === '__VERSION__') { return; } const getCssVersion = element => { var _window$getComputedSt; return element ? (_window$getComputedSt = window.getComputedStyle(element).getPropertyValue('--eufemia-version')) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.replace(/["']/g, '') : undefined; }; const cssVersion = getCssVersion(document.body) || getCssVersion(document.getElementsByClassName('dnb-core-style')[0]) || 'unknown'; if (cssVersion !== jsVersion) { const isUnknown = cssVersion === 'unknown'; const consoleArguments = [`Eufemia CSS and JS version mismatch!${isUnknown ? ' CSS version is either not loaded (are you perhaps using lazy loading?), or older than "10.25.0"' : ''}`, `\nCSS: ${cssVersion}`, `\nJS: ${jsVersion}`]; if (isUnknown) { console.warn(...consoleArguments); } else { console.error(...consoleArguments); } } }; if (document.readyState === 'complete') { window.requestAnimationFrame(runCheck); } else { window.addEventListener('load', runCheck); } } } catch (error) { console.error(error); } } //# sourceMappingURL=runCssVersionMismatchWarning.js.map