fix(docx-core): use replaceData in setLeafText to sync xmldom data/nodeValue#40
Open
stevenobiajulu wants to merge 1 commit intomainfrom
Open
fix(docx-core): use replaceData in setLeafText to sync xmldom data/nodeValue#40stevenobiajulu wants to merge 1 commit intomainfrom
stevenobiajulu wants to merge 1 commit intomainfrom
Conversation
…deValue In @xmldom/xmldom, CharacterData stores text in two separate plain properties: `data` (read by XMLSerializer) and `nodeValue` (read by `textContent`). Direct `child.nodeValue = text` assignment only updates `nodeValue`, leaving `data` stale — XMLSerializer silently outputs old text. Replace the direct assignment with `replaceData()` which updates both atomically. This fixes Issue #35 where ILPA corpus inplace reconstruction fell back to rebuild due to the round-trip safety check detecting stale serialized text. Also adds a standalone test documenting the upstream xmldom desync bug for future upstream filing, and updates integration test expectations from 'rebuild' to 'inplace' since the fix eliminates the fallback. Fixes: #35
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
setLeafTextto usereplaceData()instead of directnodeValueassignment indom-helpers.ts@xmldom/xmldom,CharacterDatastores text in two separate plain properties —data(read byXMLSerializer) andnodeValue(read bytextContent). A directchild.nodeValue = textonly updatesnodeValue, leavingdatastale.XMLSerializerthen silently outputs old text.xmldom-characterdata-nodevalue.test.tsdocumenting the desync for upstream filing at xmldom/xmldomFiles changed
src/primitives/dom-helpers.tschild.nodeValue = text→(child as CharacterData).replaceData(...)src/xmldom-characterdata-nodevalue.test.tssrc/integration/reconstruction-metadata.test.ts'inplace'instead of'rebuild'src/integration/inplace-bookmark-semantic-regression.test.tssrc/integration/stability-invariants.test.tsFixes: #35
Test plan
npm run lint:workspaces— 0 errorsnpx vitest runin docx-core — 808 tests (807 pass + 1 skip)it.fails()tests