You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
fix neglible race when loading CSS
This commit is contained in:
@ -931,8 +931,15 @@ module.exports = React.createClass({
|
|||||||
Tinter.tint(colors[0], colors[1]);
|
Tinter.tint(colors[0], colors[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// turns out that Firefox preloads the CSS for link elements with
|
||||||
|
// the disabled attribute, but Chrome doesn't.
|
||||||
|
|
||||||
let cssLoaded = false;
|
let cssLoaded = false;
|
||||||
|
|
||||||
|
styleElements[theme].onload = () => {
|
||||||
|
switchTheme();
|
||||||
|
};
|
||||||
|
|
||||||
for (let i = 0; i < document.styleSheets.length; i++) {
|
for (let i = 0; i < document.styleSheets.length; i++) {
|
||||||
const ss = document.styleSheets[i];
|
const ss = document.styleSheets[i];
|
||||||
if (ss && ss.href === styleElements[theme].href) {
|
if (ss && ss.href === styleElements[theme].href) {
|
||||||
@ -942,11 +949,8 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cssLoaded) {
|
if (cssLoaded) {
|
||||||
|
styleElements[theme].onload = undefined;
|
||||||
switchTheme();
|
switchTheme();
|
||||||
} else {
|
|
||||||
styleElements[theme].onload = () => {
|
|
||||||
switchTheme();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme === 'dark') {
|
if (theme === 'dark') {
|
||||||
|
Reference in New Issue
Block a user