Repository navigation
Keep classes a generated block's save() writes when publishing class names - #7468
Merged
Merged
Conversation
…when publishing class names ClassPublisher renamed every engine class in shipped block content. A non-core block's save() is code the plan does not carry, so a class its saved HTML holds that no className/class attribute of that block supplies is a literal in save(). Renaming or dropping it in content alone left the stored markup disagreeing with save(), and the editor reported the block invalid (copy-to-clipboard's status span, for one). Pin those classes. Generalize the published carousel save agreement test into a gate that runs every generated block's shipped save() against the published plan. Fixes #7466
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.
Fixes #7466
What
ClassPublishernow pins every engine class that a non-core block's saved HTML holds but none of that block'sclassName/classcomment attributes supplies. That class is a literal in the block's shippedsave(), so it keeps its engine name and the stored markup still round-trips. Classes supplied by attributes are renamed in the comment and the HTML together, so their round trip keeps working.This is generic. It covers every generated block with a fixed inner class (copy-to-clipboard's
blocks-engine-copy-to-clipboard__status, for one) without a per-generator declaration. #7395'sruntime_class_namesdeclaration for the carousel keeps working alongside it.Root cause:
php-transformer/src/WordPressSitePlan/ClassPublisher.php, introduced in #7326 and extended in #7347. Before this fix it renamed classes in post content only, while the generatedsave()JS kept emitting the engine names.Gate
tests/unit/published-carousel-save-agreement.phpis nowtests/unit/published-generated-block-save-agreement.php. It compiles a namespaced plan containing a carousel and a copy-to-clipboard control, finds every generated block in the published pages, templates and parts, runs that block's own shippedsave()in node, and compares the result to the stored block markup, ignoring insignificant whitespace, attribute order and class-token order.catalog-copy-to-clipboard, butsave()writesblocks-engine-copy-to-clipboard__status.Verification
tests/unit/published-generated-block-save-agreement.php: passes (fails on trunk)tests/contract/class-publisher.php: passesphp tests/run.php: the only failures are Chrome-dependent contracts that also fail on trunk locally (no Chrome)build:dev-package) and the Bossa capture subset (home, build-your-drawer, drawer/kitchen) imported into a scratch Studio site, editor validation (wp.blocks.validateBlockacross all pages, templates and parts) reports 0 invalid blocks. The stepper copy-to-clipboard blocks are still present (Copy-to-clipboard treats a bare data-copy attribute as clipboard evidence, so quantity steppers become copy buttons #7467 / Require real copy evidence before promoting a control to copy-to-clipboard #7469), but each one now validates.ssi-bossa-r8/copy-to-clipboardblocks across build-your-drawer and the four drawer pages.AI disclosure: implemented by Claude (Opus) as a Franklin/Pi subagent; Chris Huber directed the work.