Repository navigation
Conversation
… sliently dropping or failed validation error
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
3 of 6 tasks
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #83603
Keeps an
anchororariaLabelthat the block's markup still carries on a nested element, instead of removing it.Why?
applyBuiltInValidationFixesremoves one of these attributes when the markup no longer carries it, added in #82836 so that deleting anidby hand does not leave the block stuck in recovery.The check reads only the root element, because
getHTMLRootElementparses with a[data-anchor] > *selector. A block that spreadsuseBlockProps.save()onto a nested element still carries theid, just deeper, so it looked as though the attribute had been deleted.That branch also runs from the parser and the deprecation path, where nobody edited any markup. There, a block that went invalid for an unrelated reason silently lost its anchor.
No core block has this shape: each one with anchor support renders the
idon the first top-level element of its save output, and blocks whose save output is inner blocks only are skipped by the existinginnerHTML.trim()guard. The exposure is third-partyapiVersion2 blocks and old deprecations.How?
The removal branch now confirms the value is absent from the whole markup before deleting it:
hasHTMLAttributeValuematches on the value rather than on the attribute being present anywhere, so a block whose inner blocks carry their own anchors is not mistaken for one that still has its own.Testing Instructions
No core block can reach this, so the repro registers one from the browser console. Nothing needs building.
Ctrl/Cmd + Shift + Alt + M) and paste. Theidis on the inner<p>, and the text differs from the save output so the block is invalid for a reason unrelated to the anchor:Before:
anchor: undefined, removed although the markup still has it.After:
anchor: 'keep-me'.Regression check
Deleting an
idfor real must still drop the anchor. Paste this into the code editor and switch to the visual editor — the heading should render without a warning and Advanced → HTML anchor should be empty:Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A
Use of AI Tools