-
Notifications
You must be signed in to change notification settings - Fork 4.7k
A11y: Add script-module #65101
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
A11y: Add script-module #65101
Conversation
|
Size Change: +972 B (+0.06%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
4f389e8 to
0c132f6
Compare
84b7339 to
b6256a4
Compare
7c7702a to
5bf5899
Compare
4dd71f6 to
a79ceda
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
gziolo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/experimental/script-modules.php
Outdated
| add_filter( | ||
| 'script_module_data_@wordpress/a11y', | ||
| function ( $data ) { | ||
| $data['i18n'] = array( 'Notifications' => __( 'Notifications' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, the same feedback applies as the one shared by @swissspidy in #65123 (comment). I echo that this is really a step backwards from the JS I18N mechanism we implemented all those years ago. However, I hope we can address that with the next planned steps when we replicate the same approach for @wordpress/i18n as for the @wordpress/a11y package.
|
Flaky tests detected in 1b86c49. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10828924375
|



What?
Add a
@wordpress/a11yWordPress Script Module. The script module has the same public API as thewp-a11yscript.domReadypackage should not be necessary. Since modules are deferred,setupcan be called directly when the module is evaluated.i18nscript module at this time. The necessary string "Notifications" is translated on the server and passed to the package via script module data.Most of the changes here are moving some functions around so that the script and the module form of this package rely on the same underlying implementations.
This is useful for the Interactivity Router and other work such as #62906.
Depends on #65064
Related PRs:
Testing Instructions
This is unused at the moment in Gutenberg, but can be tested by other packages. #65123 uses the a11y script module in the interactivity-router package. The behavior can be demonstrated there, for example via the playground.