Repository navigation
fix: SVG elements keep the case of their tagName in an HTML document - #354
Open
jonasporto wants to merge 1 commit into
Open
jonasporto wants to merge 1 commit into
jonasporto wants to merge 1 commit into
Conversation
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 #344
In an HTML document,
tagNameandnodeNameof an SVG element came back upper-cased ("PATH","SVG"), both for parsed elements and forcreateElementNSones. Browsers upper-case only elements in the HTML namespace (DOM: HTML-uppercased qualified name), so an SVG<path>reports"path". Still the case on 0.18.14 andmain(e2ee208).Code written for browsers branches on it: mermaid's
mergePathskeeps the children whosetagName === 'path', so a shape rendered on linkedom came out with an emptyd.Change
SVGElementoverrides thenodeNameandtagNamegetters to returnlocalName.ElementkeepslocalCasefor the HTML namespace.getElementsByTagNamecompareslocalNamefirst, so it keeps matching'path'and'PATH'as before.cjs/svg/element.jsis regenerated withnpm run cjs. The test is intest/svg/element.js(parsed<svg>and<rect>,createElementNS, and<html>still upper-cased);npm testpasses with the same coverage asmain.Not covered: a parsed
<foreignObject>has thelocalName"foreignobject"(browsers adjust the case of a few SVG names while parsing). Separate matter.