Skip to content

fix: fix /children directive on root fragment (take 2)#19

Merged
hi-ogawa merged 15 commits into
vitest-dev:masterfrom
hi-ogawa:fix-aria-template-root-directive
Apr 28, 2026
Merged

fix: fix /children directive on root fragment (take 2)#19
hi-ogawa merged 15 commits into
vitest-dev:masterfrom
hi-ogawa:fix-aria-template-root-directive

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes root-level /children directives on ARIA templates. Previously, the matcher outright ignored containerMode on the root template fragment, so root /children: equal and /children: deep-equal behaved like default contain matching.

The fix treats fragment as an internal root wrapper. matchAriaTree now lifts the root wrapper’s containerMode before unwrapping synthetic actual/template fragments, then passes that mode into the top-level child-list merge. When the match passes, the root directive is restored into resolved; when it fails, it is dropped consistently with existing failed-branch directive behavior.

To keep this model explicit, YAML-authored fragment roles are rejected and recursive matching asserts that fragment wrappers have already been unwrapped at the root boundary.

@pkg-pr-new

pkg-pr-new Bot commented Apr 28, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ivya@19

commit: bf06565

hi-ogawa and others added 13 commits April 28, 2026 11:23
Reject explicit fragment role in ARIA templates and preserve root-level children directives at the match boundary.

Co-authored-by: Codex <noreply@openai.com>
Reduce aria template parser churn

Keep the fragment role validation while restoring the prior local shape of role parsing.

Co-authored-by: Codex <noreply@openai.com>
Reject authored fragment roles and unwrap synthetic fragment wrappers only at the match root boundary.

Co-authored-by: Codex <noreply@openai.com>
@hi-ogawa

Copy link
Copy Markdown
Collaborator Author

@codex review

@hi-ogawa
hi-ogawa marked this pull request as ready for review April 28, 2026 03:53
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hi-ogawa
hi-ogawa requested a review from Copilot April 28, 2026 04:01
@hi-ogawa
hi-ogawa merged commit 3bfd7be into vitest-dev:master Apr 28, 2026
6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes root-level /children directives on ARIA template fragments by treating fragment as an internal root wrapper and correctly applying the root fragment’s containerMode during top-level child-list merging.

Changes:

  • Normalize synthetic root fragment wrappers in matchAriaTree, lifting/restoring root /children container mode semantics.
  • Reject YAML-authored fragment roles at parse time and assert that fragment wrappers are only handled at the root boundary.
  • Add/adjust tests for root /children: equal|deep-equal behavior and root directive rendering.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/aria.test.ts Adds coverage for root-level /children directives, fragment-role rejection, and root directive rendering.
src/aria/template.ts Renders root fragment /children directive when container mode is non-default.
src/aria/match.ts Applies root fragment containerMode correctly and enforces the “root-only fragment wrapper” invariant.
src/aria/folk/isomorphic/ariaSnapshot.ts Rejects explicit fragment role in YAML parsing to preserve matching invariants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/aria/match.ts
Comment on lines +141 to +145
function isAriaTemplateFragement(
template: AriaTemplateNode
): template is AriaTemplateRoleNode {
return template.kind === 'role' && template.role === 'fragment'
}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isAriaTemplateFragement is misspelled ("Fragement" vs "Fragment"), which makes the helper harder to discover/search and is easy to propagate into new call sites. Rename it to isAriaTemplateFragment (and update all references) to keep naming consistent with the fragment concept used throughout this module.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants