Restore the style cache in a way that works for multiple components and prevents the jittering on Application rerender
This commit is contained in:
parent
7b29fc8d6f
commit
1535e07f77
1 changed files with 13 additions and 7 deletions
|
|
@ -11,9 +11,9 @@ export function StyledShadowElement(Base) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The stringified CSS to use
|
* The stringified CSS to use
|
||||||
* @type {string}
|
* @type {Map<string, string>}
|
||||||
*/
|
*/
|
||||||
static _styles;
|
static _styles = new Map();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTML element of the stylesheet
|
* The HTML element of the stylesheet
|
||||||
|
|
@ -48,11 +48,17 @@ export function StyledShadowElement(Base) {
|
||||||
|
|
||||||
_getStyles() {
|
_getStyles() {
|
||||||
// TODO: Cache the CSS content in a more sane way that doesn't break
|
// TODO: Cache the CSS content in a more sane way that doesn't break
|
||||||
fetch(`./systems/${game.system.id}/templates/${this.constructor._stylePath}`)
|
const stylePath = this.constructor._stylePath;
|
||||||
|
if (this.constructor._styles.has(stylePath)) {
|
||||||
|
this._style.innerHTML = this.constructor._styles.get(stylePath);
|
||||||
|
} else {
|
||||||
|
fetch(`./systems/${game.system.id}/templates/${stylePath}`)
|
||||||
.then(r => r.text())
|
.then(r => r.text())
|
||||||
.then(t => {
|
.then(t => {
|
||||||
|
this.constructor._styles.set(stylePath, t);
|
||||||
this._style.innerHTML = t;
|
this._style.innerHTML = t;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue