-
Notifications
You must be signed in to change notification settings - Fork 436
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
Update the html lang attribute #967
Comments
Turbo should probably monitor changes to the Until that support is baked in, applications that drive to pages with different |
Closes [hotwired#967][] Change the `<html>` element's `[lang]` attribute during navigation. Currently, this isn't possible from applications (without a lot of trouble), since the [turbo:before-render][] event is scoped to the `newBody`. In order to support this behavior, change the `PageSnapshot` constructor to accept an instance of [HTMLHtmlElement][] (the `<html>` element) so that that element can be accessible from the `PageRenderer`. [hotwired#967]: hotwired#967 [turbo:before-render]: https://turbo.hotwired.dev/reference/events [HTMLHtmlElement]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHtmlElement
I've opened #1035 to implement this behavior. |
I came here after encountering this exact issue: the document's Thank you so much @seanpdoyle for the PR. |
Closes [#967][] Change the `<html>` element's `[lang]` attribute during navigation. Currently, this isn't possible from applications (without a lot of trouble), since the [turbo:before-render][] event is scoped to the `newBody`. In order to support this behavior, change the `PageSnapshot` constructor to accept an instance of [HTMLHtmlElement][] (the `<html>` element) so that that element can be accessible from the `PageRenderer`. [#967]: #967 [turbo:before-render]: https://turbo.hotwired.dev/reference/events [HTMLHtmlElement]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHtmlElement
Hi,
In an application, I have the
lang
attribute set on the<html>
tag.When the user switches the locale, the body is changed with Turbo.
However, the
lang
attribute is not updated by Turbo, and some of my JavaScript relies on this attribute to use the correct locale.I know that I could either add an event listener listening to a Turbo event to update the attribute, or trigger a full page refresh instead.
Would it make sense for Turbo to also update the
lang
attribute by default instead of adding custom logic?The text was updated successfully, but these errors were encountered: