Skip to content

Commit

Permalink
Use documentLocaleSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Aug 31, 2023
1 parent 6219fe3 commit 524b84c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
"access": "public"
},
"dependencies": {
"@rollup/plugin-node-resolve": "^15",
"@brightspace-ui/intl": "^3.13.2",
"@open-wc/testing": "^3",
"@rollup/plugin-node-resolve": "^15",
"@web/config-loader": "^0.2",
"@web/dev-server": "^0.2",
"@web/rollup-plugin-html": "^2",
Expand Down
9 changes: 6 additions & 3 deletions src/browser/reset.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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',
DEFAULT_MATHJAX_RENDER_LATEX = false,
DEFAULT_VIEWPORT_HEIGHT = 800,
DEFAULT_VIEWPORT_WIDTH = 800;

let currentLang = undefined,
const documentLocaleSettings = getDocumentLocaleSettings();

let
currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
currentRtl = false,
currentViewportHeight = 0,
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 524b84c

Please sign in to comment.