mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:52:50 +08: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() {
|
||||
return (
|
||||
window.getComputedStyle(document.querySelector("html")).direction === "rtl"
|
||||
);
|
||||
return document.documentElement.classList.contains("rtl");
|
||||
}
|
||||
|
||||
export default Component.extend(
|
||||
|
|
Loading…
Reference in New Issue
Block a user