fix(export): preserve attributes before an empty style attribute (#682)#709
Closed
tongshu2023 wants to merge 2 commits into
Closed
fix(export): preserve attributes before an empty style attribute (#682)#709tongshu2023 wants to merge 2 commits into
tongshu2023 wants to merge 2 commits into
Conversation
Contributor
Author
|
Apologies — I missed that #683 (opened earlier by the team) already covers this. Closing in favor of that PR. The tests added here are free to cherry-pick if useful. |
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.
Bug
formatAttributesinlib/export/html-parser/stringify.tsdrops every attribute accumulated before an emptystyleattribute, because the empty-style branch returns''— which becomes the newreduceaccumulator — instead of the accumulated string. Closes #682.For an element like
{ id: 'box', style: '' }, serialization produced<div>instead of<div id='box'>— theid(and any other earlier attribute) silently disappears from exported HTML.Fix
Return the accumulator unchanged so the empty
styleis skipped without discarding prior attributes:Tests
Adds
tests/export/stringify.test.ts(none existed for this module):formatAttributes: value attribute quoting,null→ boolean attribute, single→double quote switch when the value contains', emptystyleomitted, regression: attributes before an emptystyleare kept, non-emptystylepreservedtoHTML: element whose first attribute precedes an emptystyle(regression), void-tag serialization, text/comment passthroughVerification
prettier --check,eslint, andtsc --noEmitall clean.