/
githubmirror
/
element
Обзор
Документация
Войти
/
githubmirror
/
element
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
examples/components/theme/utils.js
24 строки
672 B
iamkun
Chore: support theme configuration (#15190)
24 апр 2019, 14:52
24 апр 2019, 14:52
ac3aa99
Код
Авторство
О чём код?
export const isEmptyObject = (obj) => (JSON.stringify(obj) === '{}'); export const getThemeConfigObject = (config) => { try { const conf = JSON.parse(config); const { global, local } = conf; if (!isEmptyObject(global) || !isEmptyObject(local)) { return conf; } return false; } catch (e) { return false; } }; export const updateDomHeadStyle = (id, styleContent) => { let styleTag = document.getElementById(id); if (!styleTag) { styleTag = document.createElement('style'); styleTag.setAttribute('id', id); document.head.appendChild(styleTag); } styleTag.innerText = styleContent.replace(/@font-face{[^}]+}/, ''); };