Set correct lang attribute#5479
Conversation
| @@ -1,5 +1,5 @@ | |||
| <!DOCTYPE html> | |||
| <html lang="en"> | |||
| <html lang=""> | |||
There was a problem hiding this comment.
Why not remove the attribute completely instead of initializing it as an empty value?
There was a problem hiding this comment.
Because an empty string means unknown language
There was a problem hiding this comment.
Actually, you are right, it should only be set to an empty string when you want to overrule a parent element to unknown.
| this._initializeLocalizeLite(); | ||
| } | ||
| if (changedProperties.has("language")) { | ||
| document.querySelector("html")!.setAttribute("lang", this.language!); |
There was a problem hiding this comment.
We shouldn't do this here. This mixin is added to a lot of elements, now they all update the lang tag
There was a problem hiding this comment.
As far as I know this is only used for elements that are not inside home-assistant like onboarding and auth with their own entrypoint?
There was a problem hiding this comment.
On authorize it would happen 3 times as there are 3 elements that use the mixin there, will look for a solution for that.
| if (changedProperties.has("language")) { | ||
| const html = document.querySelector("html")!; | ||
| if (html.getAttribute("lang") !== this.language) { | ||
| html.setAttribute("lang", this.language!); | ||
| } | ||
| } |
There was a problem hiding this comment.
Even if it's only used at a couple of pages, let's still not put it here. Let's put it in the main elements for onboarding/authorize.
Breaking change
Proposed change
Fixes #5076
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: