fix(element): Handle unmatched closing tags in createInterpolateElement#71413
fix(element): Handle unmatched closing tags in createInterpolateElement#71413SinghCod3r wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @SinghCod3r! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
610d147 to
613b933
Compare
|
Hi @ajitbohra, This PR fixes #60843 by improving error handling in ✅ Prevents crashes when an unmatched closing tag is found in translated strings. ✅ Logs a clear error to the console and treats the unmatched tag as plain text. ✅ Keeps processing other elements without breaking the app. ✅ Added a dedicated unit test ( Testing All existing unit tests pass locally. Verified manually with:
→ The application no longer crashes, and an error message appears in the console as expected. Notes Some CI checks (JavaScript unit tests + Playwright E2E) are failing. My new test passes independently, so these appear unrelated/fragile. The Props bot flagged my GitHub The PR is missing a [Type] Bug label, which maintainers may need to apply for it to merge. This change is ready for your review. Please let me know if you’d like further adjustments |
t-hamano
left a comment
There was a problem hiding this comment.
@SinghCod3r Thanks for the PR!
This PR appears to contain unintentional file moves and deletions. Could you address the following so we can review it?
- Restore the unit test file to its original location:
packages/element/src/create-interpolate-element.test.tsx=>packages/element/src/test/create-interpolate-element.js - Restore the deleted
README.mdcontent
Adds a check to ensure that a closing tag has a corresponding opening tag before processing. If an unmatched closing tag is found, an error is logged to the console, and the tag is treated as plain text instead of causing a critical crash. This change also includes a new unit test to verify the correct behavior and prevent future regressions. Fixes WordPress#60843
613b933 to
76ceed7
Compare
|
@t-hamano , i guess its resolved now.. |

Description
This pull request addresses an issue where the
createInterpolateElement()function throws a criticalTypeErrorif it encounters a closing HTML tag that does not have a corresponding opening tag. This is particularly problematic for translated strings, where such errors can be accidentally introduced.This fix adds a check to validate that a closing tag has a matching opening tag on the stack. If no match is found:
A new unit test has also been added to confirm this behavior and prevent future regressions.
Fixes #60843
How has this been tested?
packages/element/src/test/create-interpolate-element.test.jsthat specifically checks for the unmatched closer scenario. Confirmed this test passes.Types of changes