mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-26 23:53:59 +00:00
- Optimize parseStyle method to run a single RegExp replace - Abstract DOM manipulation to check for VUE_ENV first - Add theme name to <md-theme> element when it would render its own tag - Recompute styles when a new set of selectors is added (via styles.push) - Use computed property to find closest themed ancestor for mixin - Only grab md-name attribute from an md-theme component (<md-table-edit> uses the md-name attribute for <input> tags)
38 lines
1 KiB
JavaScript
38 lines
1 KiB
JavaScript
export var changeHtmlMetaColor;
|
|
export var createNewStyleElement;
|
|
|
|
if (process.env.VUE_ENV !== 'server') {
|
|
changeHtmlMetaColor = (color, themeClass, previousClass) => {
|
|
var elem = document.querySelector('meta[name="theme-color"]');
|
|
|
|
if (elem) {
|
|
elem.setAttribute('content', color);
|
|
} else {
|
|
elem = document.createElement('meta');
|
|
elem.setAttribute('name', 'theme-color');
|
|
elem.setAttribute('content', color);
|
|
|
|
document.head.appendChild(elem);
|
|
}
|
|
|
|
document.body.classList.remove(previousClass);
|
|
document.body.classList.add(themeClass);
|
|
};
|
|
|
|
createNewStyleElement = (style, styleId) => {
|
|
const head = document.head;
|
|
const styleElement = head.querySelector('#' + styleId);
|
|
|
|
if (!styleElement) {
|
|
const newTag = document.createElement('style');
|
|
|
|
newTag.type = 'text/css';
|
|
newTag.id = styleId;
|
|
newTag.textContent = style;
|
|
|
|
head.appendChild(newTag);
|
|
} else {
|
|
styleElement.textContent = style;
|
|
}
|
|
};
|
|
}
|