Repository navigation
fix: preserve explicit HTML fragments in native intent - #194
Merged
Merged
Conversation
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.
Problem
Explicit Custom HTML in native intent silently becomes an empty block on WordPress 7.1. Its
contentattribute is local to the editor; serialization now readsinnerContent. Small authored SVG and form fragments therefore disappear even though validation reports success.Solution
Reuse the converter's existing HTML construction helper for intent
core/html. Preserve supplied attributes and dropped-attribute diagnostics, keeptextprecedence, and reject non-string content. Converter fallback behavior remains unchanged.src/intent/index.tscreateHtmlFallbackand intent constructorsrc/convert/fallback.tsDiff
3 files, +60 / -6.
Testing & verification
Reviewed revision:
d3f6293e97ea2dd36b5611abb1ad966cbe60eebb· Environment: Node 22 locally; WordPress 7.1 / PHP 8.4 in OrbStack.npm test -- dev/test/intent.test.ts dev/test/convert.test.ts dev/test/coverage.test.ts: 95 passed.npm run typecheck,npm run build,npm run check:private,git diff --check: passed.Actual general CLI apply updated a native page containing both localized fragments, with successful full field readback. A real page editor edit, Save and reopen retained both SVG/form fragments with zero invalid blocks; restoring the edit returned exactly to compiled content. Native theme files also saved byte-for-byte unchanged.
Converter selection and existing fallback behavior are unchanged; this does not add a conversion rule or change benchmark scores.
Exact-head CI 38301931599: Node 22.13/24, package-boundary, WordPress proof and CI scope passed.
Not verified: no production apply or release. The large-mutation transport fix in #193 is already merged.
Risk / rollout
Callers that explicitly supply non-string Custom HTML content now get a clear failure instead of silent empty output. Detection: exact payload roundtrip checks and visible live fragments. Rollback: revert these three files; that reintroduces silent intent fragment loss and does not undo WordPress writes.