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:
David Taylor 2021-11-19 10:17:23 +00:00 committed by GitHub
parent 1566cd2048
commit 2153011cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(