Repository navigation
Conversation
`speak()` removed anything between angle brackets, so a filename such as `report <draft>.pdf` was announced without `<draft>`, and `1 < 2 and 3 > 2` lost its middle. It now removes only HTML elements the browser knows and comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +484 B (+0.01%) Total Size: 8.86 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the items list via UP/DOWN arrow keys in
|
Checking a tag name with `document.createElement()` ran the constructor of a registered custom element. Names are now checked in an inert document. `<!…>` is stripped only for comments and doctypes, and the changelog and Storybook note state what is still removed.
A tag name now ends at ASCII whitespace or `/`, so a valid custom element name such as `wp-notice.v2` is stripped, and a name the browser rejects is kept as text. Comments are removed whole first, so angle brackets inside them aren't announced. Also restores the escaped no-break space.
|
Wondering if an alternative to creating a whole DOM would be to only strip things that look like HTML tags if there's a matching closing tag (or self-closing), e.g. using a regular expression capture group plus a |
|
There's a related case in #78485 where the message strips out angle brackets before sending to I think that, in principle, this PR is an improvement - it does a better job of avoiding stripping unneeded things; I'm just wondering if it wouldn't be helpful to document what people need to do if they need to communicate an HTML element as a value within the spoken message. |
A tag is now removed only when the message shows that it is markup: it is self-closing, its name has both an opening and a closing tag in the message, or it is a void element. This replaces the lookup of the name in an inert document, so an HTML element name on its own, such as the `<b>` in `notes <b>.txt` or a `<search>` that a message names, is announced. Paired SVG and MathML tags are removed again. The filter no longer needs the DOM, so its test runs without jsdom. The `speak()` docs now say which tags are removed and how to name an HTML element in a message.
|
Thanks both, I changed the approach in be4bc8c. @aduth I went with your idea and dropped the DOM lookup. @joedolson a nice side effect is that a lone The trade-off is that HTML with missing closing tags, like |
What?
Follow-up to #86732.
speak()now removes text in angle brackets only when the message shows that it is an HTML tag. Other text in angle brackets is announced, soreport <draft>.pdfis no longer read as "report .pdf".Why?
speak()removed everything between<and>. A filename such asreport <draft>.pdflost<draft>, and1 < 2 and 3 > 2lost "2 and 3". #86732 found this while building the Selecting Local Files patterns, and the page had to warn about it.How?
Comments and doctypes are removed whole first. After that, a tag is removed in three cases:
<br/>.<strong>and</strong>.<br>or<img>. A void element never has a closing tag.Everything else in angle brackets stays. That includes an HTML element name on its own, so
notes <b>.txtkeeps<b>, and a message can name<search>or<form>.Existing callers that pass markup, such as
<p>…</p>,<a href="…">…</a>,<br>, or<br/>, get the same result as before.The
speak()docs now state this rule, and they say how to name an HTML element in a message.Why not check the tag name against the browser's elements?
An earlier revision of this PR looked up each name in an inert document and removed the tag when the browser knew the element. That removed every HTML element name, so it could not keep
notes <b>.txtor the<search>that the Search block names in #78485. It also kept SVG tags such as<path>as text, and the result depended on the browser's list of elements. The closing-tag rule came from review feedback. It needs no DOM, so the filter test runs without jsdom again.Limits
<p>One<p>Twoor an<li>without</li>, is now announced with its tags. Ontrunkthose tags are removed.photo <img>.pngis announced as "photo .png". The Selecting Local Files page states this limit.<b>Added</b> notes <b>.txt, the<b>of the filename is removed.Testing Instructions
trunk, the result is"Added report .pdf". With this PR, it is"Added report <draft>.pdf".trunk, the result is"Added notes .txt". With this PR, it is"Added notes <b>.txt"." Saved as draft ", the same as ontrunk.report <draft>.pdf(macOS or Linux allow<and>in file names). The announcement includes<draft>.Testing Instructions for Keyboard
No UI change.
Use of AI Tools
Claude Code wrote the fix, tests, and description from the follow-up listed in #86732. Review rounds with GPT-6.2 Astra shaped the earlier revision that checked tag names. Claude Code then replaced that check with the closing-tag rule and added the
speak()docs, both in response to review feedback on this PR.🤖 Generated with Claude Code