fix: sync sourceCodeLocation.attrs keys with adjusted SVG/MathML/XML attribute names#1705
Open
TrevorBurnham wants to merge 1 commit intoinikulin:masterfrom
Open
fix: sync sourceCodeLocation.attrs keys with adjusted SVG/MathML/XML attribute names#1705TrevorBurnham wants to merge 1 commit intoinikulin:masterfrom
TrevorBurnham wants to merge 1 commit intoinikulin:masterfrom
Conversation
…attribute names When parsing foreign content (SVG, MathML), attribute names are adjusted from lowercase to their spec-correct casing (e.g. viewbox -> viewBox). The location info keys in token.location.attrs were not updated to match, causing a mismatch where attrs[i].name and Object.keys(location.attrs) would differ. Fixes inikulin#318
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.
Closes #318
Summary
When parsing foreign content (SVG, MathML), parse5 adjusts attribute names from their tokenizer-lowercased form to spec-correct casing (e.g.
viewbox→viewBox). However, the keys insourceCodeLocation.attrswere not updated to match, soelement.attrswould haveviewBoxwhilesourceCodeLocation.attrsonly hadviewbox.Changes
packages/parse5/lib/common/foreign-content.ts— UpdatedadjustTokenSVGAttrs,adjustTokenMathMLAttrs, andadjustTokenXMLAttrsto also rename the corresponding key intoken.location.attrswhen adjusting an attribute name.packages/parse5/lib/parser/parser-location-info.test.ts— Added a regression test parsing<svg viewBox="0 0 100 100">and asserting thatlocation.attrsuses the camelCase keyviewBox, notviewbox.Before
After