From 2153011cdb2a4e8cbafcdf900bcedddb40d65a5b Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 19 Nov 2021 10:17:23 +0000 Subject: [PATCH] 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. --- .../javascripts/select-kit/addon/components/select-kit.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js index 2bc430fd29..e115ee9b2b 100644 --- a/app/assets/javascripts/select-kit/addon/components/select-kit.js +++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js @@ -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(