Skip to content

Commit 7193dfa

Browse files
review(#622): keep the class-name contract and live-DOM rationale
1 parent 6548b34 commit 7193dfa

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎website/theme/index.tsx‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ const Layout = () => (
152152
* a `<div>` instead of becoming a `<button>` because `NavHamburger` (shown at
153153
* widths ≤ 1280 px) mounts the switch inside its own `<button>`, and a
154154
* `<button>` inside a `<button>` is invalid HTML that React reports on every
155-
* render. That nested copy is
156-
* the hamburger's own control, so once mounted the switch checks whether it
157-
* sits inside a `<button>` and, if so, renders as the plain click target the
158-
* default theme used — a focusable `role="button"` inside a button would be
159-
* nested interactive content with undefined keyboard behaviour. `aria-pressed`
160-
* and the nesting check only apply after mount: the SSG HTML is rendered with
161-
* the default theme while the client's first render already knows the stored
162-
* preference, so a state attribute in the initial markup would mismatch on
163-
* hydration. The original's view-transition animation
155+
* render. That nested copy is the hamburger's own control, so once mounted the
156+
* switch checks whether it sits inside a `<button>` and, if so, renders as the
157+
* plain click target the default theme used — a focusable `role="button"`
158+
* inside a button would be nested interactive content with undefined keyboard
159+
* behaviour. The theme's own class names are kept so its CSS still applies.
160+
* `aria-pressed` and the nesting check only apply after mount: the SSG HTML is
161+
* rendered with the default theme while the client's first render already
162+
* knows the stored preference, so a state attribute in the initial markup
163+
* would mismatch on hydration. The original's view-transition animation
164164
* (`themeConfig.enableAppearanceAnimation`, off for this site) is not
165165
* reproduced.
166166
*/
@@ -223,8 +223,9 @@ const socialLinkName = (href: string): string => {
223223
* `NavScreen` import `SocialLinks` from `@rspress/core/theme`, so this named
224224
* export replaces it. The anchor is created inside the default component and
225225
* its icon comes from a build-time virtual module, so rather than restating
226-
* the component the name is set on the rendered anchors after each render.
227-
* `github-stars` links already carry their own label and are left alone.
226+
* the component the name is set on the rendered anchors after each render,
227+
* which is what assistive technology reads. `github-stars` links already carry
228+
* their own label and are left alone.
228229
*/
229230
const SocialLinks = (props: { socialLinks?: SocialLink[] }) => {
230231
const ref = useRef<HTMLDivElement>(null);

0 commit comments

Comments
 (0)