From 81b18dc4e530d585e9482b77be1bba981c2500a2 Mon Sep 17 00:00:00 2001 From: Danny Gleckler Date: Thu, 31 Aug 2023 18:55:59 -0400 Subject: [PATCH] Use documentLocaleSettings --- package-lock.json | 6 ++++++ package.json | 3 ++- src/browser/reset.js | 9 ++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index c36eb712..6fa7fa68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.31.0", "license": "Apache-2.0", "dependencies": { + "@brightspace-ui/intl": "^3", "@open-wc/testing": "^3", "@rollup/plugin-node-resolve": "^15", "@web/config-loader": "^0.2", @@ -403,6 +404,11 @@ "node": ">=6.9.0" } }, + "node_modules/@brightspace-ui/intl": { + "version": "3.13.2", + "resolved": "https://registry.npmjs.org/@brightspace-ui/intl/-/intl-3.13.2.tgz", + "integrity": "sha512-TUb6SZqsi3P6CbREnnwhqGOWu7Svx9JQ1Rw4zRVLj4IozG7kIYu2SfgUrITLYY/moRtiAJTV0wlnYczfBHfG7A==" + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", diff --git a/package.json b/package.json index 89e9ef30..f5e99383 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,9 @@ "access": "public" }, "dependencies": { - "@rollup/plugin-node-resolve": "^15", + "@brightspace-ui/intl": "^3", "@open-wc/testing": "^3", + "@rollup/plugin-node-resolve": "^15", "@web/config-loader": "^0.2", "@web/dev-server": "^0.2", "@web/rollup-plugin-html": "^2", diff --git a/src/browser/reset.js b/src/browser/reset.js index 3798d103..21148a0d 100644 --- a/src/browser/reset.js +++ b/src/browser/reset.js @@ -1,4 +1,5 @@ import { sendMouse, setViewport } from '@web/test-runner-commands'; +import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js'; import { nextFrame } from '@open-wc/testing'; const DEFAULT_LANG = 'en', @@ -6,7 +7,9 @@ const DEFAULT_LANG = 'en', DEFAULT_VIEWPORT_HEIGHT = 800, DEFAULT_VIEWPORT_WIDTH = 800; -let currentLang = undefined, +const documentLocaleSettings = getDocumentLocaleSettings(); + +let currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX, currentRtl = false, currentViewportHeight = 0, @@ -57,9 +60,9 @@ export async function reset(opts = {}) { currentRtl = opts.rtl; } - if (opts.lang !== currentLang) { + if (opts.lang !== documentLocaleSettings.language) { document.documentElement.setAttribute('lang', opts.lang); - currentLang = opts.lang; + documentLocaleSettings.language = opts.lang; awaitNextFrame = true; }