dashorst opened a new pull request, #1870:
URL: https://github.com/apache/wicket/pull/1870
Pages now render `lang` on their `<html>` tag from the page locale, and
`dir="rtl"` when that language is written right to left. Screen readers pick
their pronunciation from `lang` (WCAG 2.2 SC 3.1.1, level A). Until now an
application had to bind `<html>` to a `TransparentWebMarkupContainer` to get it.
`WebPage#onHtmlTag(ComponentTag)` receives a mutable copy of the `<html>`
tag on every full render:
- **`lang`:** set to `getLocale().toLanguageTag()`, unless the markup has
`lang` or `xml:lang`, or the locale has no language (`Locale.ROOT`).
- **`dir="rtl"`:** set when `Session.isRtlLanguage` (WICKET-6943) recognises
the language, unless the markup has its own `dir` or declares its own `lang`.
- **Opting out:** put `dir="ltr"` on `<html>` in the markup, or call
`tag.remove("dir")` after `super.onHtmlTag(tag)` in the base page.
- **Extending:** override the method to add document-wide attributes, such
as a theme class or `data-theme`.
The commit message carries the design decisions: why there is no setting, no
`IOnComponentTagListener` call, no contributor mechanism and no hook for
`<head>` or `<body>`. It also explains why `<html>` attributes can't change on
an Ajax request. The draft migration-guide wording is there too.
## Where to look
- **Core:**
- `WebPage`: `renderNext` and `onHtmlTag`.
- `HtmlTagHandler` (new, page markup only): keeps each `<html>` tag as a
tag with id `_html_` and the new `ComponentTag.RENDERED_BY_PAGE` flag. No
component is created.
- `MarkupContainer` and `TagUtils`: queueing ignores the flagged tag, and
`findTagMarkup` keeps looking inside it, as it does for `<head>`. Without this,
components inside `<html>` are no longer found or dequeued.
- `HtmlTagTest`: 16 tests covering locale changes between renders, markup
`lang`/`xml:lang`/`dir`, `Locale.ROOT`, RTL and the Latin-script exception, the
opt-out, a bound `<html wicket:id>`, markup inheritance, queueing and an Ajax
update.
- **Mechanical:**
- 234 expected-output files in wicket-core-tests and wicket-extensions,
each changed only on its `<html>` line.
- Two Java tests with a hard-coded `<html>`.
- **Small test fixes:**
- `AjaxBehaviorEnabledTest` built its own `WicketTester` and rendered with
the JVM default locale, so it failed on non-US machines. It now uses
`newWicketTester`, which pins `Locale.US`.
- The `OpenCloseTagExpander` test markup now quotes an `xmlns:wicket`
value, because the parser mangles unquoted values containing `/` or `:` (#1864).
## Risk
- **Every page's output changes.** Pages without `lang` in their markup get
the attribute, and RTL locales also get `dir="rtl"`. Tests that compare
rendered pages with expected files need updating.
- **The `<html>` tag is now written from its parsed attributes, like a
component tag.** Values get double quotes, a valueless `xmlns:wicket` becomes
`xmlns:wicket=""`, and a tag spread over several lines is written on one.
- **RTL layout changes.** An application with RTL translations and an
LTR-only stylesheet sees its layout mirror until it opts out.
## Verification
- `mvn clean verify -Pjs-test` passed in two parts: the first run stopped at
one extensions expected file, and the run resumed from wicket-extensions passed
after fixing it.
- After adding `dir` and rebasing on master, wicket-core-tests (2569) and
wicket-extensions (141) pass.
- wicket-core-tests and wicket-extensions also pass with the JVM locale set
to `nl_NL`.
Closes #1848
Generated-by: Claude Code (Claude Opus 5.5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]