mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Use more efficient text-direction check in select-kit init (#15015)
Calling `window.getComputedStyle` during initialization causes the browser to pause and 'Recalculate Style'. On my machine, this adds about 7ms to boot time. Instead, we can check for the `rtl` class on the html element, which is added by the server, and doesn't require computing styles.
This commit is contained in:
parent
1566cd2048
commit
2153011cdb
@ -27,9 +27,7 @@ const SELECT_KIT_OPTIONS = Mixin.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function isDocumentRTL() {
|
function isDocumentRTL() {
|
||||||
return (
|
return document.documentElement.classList.contains("rtl");
|
||||||
window.getComputedStyle(document.querySelector("html")).direction === "rtl"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Component.extend(
|
export default Component.extend(
|
||||||
|
Loading…
Reference in New Issue
Block a user