-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use documentLocaleSettings #156
Conversation
524b84c
to
81b18dc
Compare
56fd48c
to
9ecc8f2
Compare
opts.lang ??= ''; | ||
if (documentLocaleSettings.lamguage !== opts.lang) { | ||
document.documentElement.lang = opts.lang; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Avoids coercion of nullish values to strings (i.e.
<html lang="null" ...>
) - Compares against
documentLocaleSettings
for guaranteed latest change - Sets
document.documentElement.lang
to guarantee all values are in sync (documentLocaleSettings
is observing this value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, good call.
🎉 This PR is included in version 0.31.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -36,8 +36,9 @@ | |||
"access": "public" | |||
}, | |||
"dependencies": { | |||
"@rollup/plugin-node-resolve": "^15", | |||
"@brightspace-ui/intl": "^3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we can't use @brightspace-ui/testing
in intl
, or would that still work? 🤔 Looks like we use mocha directly anyways so maybe doesn't matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that's what it implies. I'm OK with that, since yeah keeping intl
bare bones seems like a good call anyway given how low-level it is.
document.documentElement.setAttribute('lang', opts.lang); | ||
currentLang = opts.lang; | ||
opts.lang ??= ''; | ||
if (documentLocaleSettings.lamguage !== opts.lang) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this should be "language" and this is working right now because this is always true?
Lots of things are listening for changes to the common
DocumentLocaleSettings
instance, so use that instead of localcurrentLang
, which can get out of sync of the lang is changed before the nextreset
.d2l-localize-behavior
blew up in all kinds of weird ways when I switched to the newfixture
without this.