Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#1151] Skips svg elements when innerText is used #1753

Merged
merged 6 commits into from
Mar 6, 2025

Conversation

karpiuMG
Copy link
Contributor

for skipping svg element a change is needed for recognizing tag names as HTML Parser parse svg elements in a way that svg tagName is lowercase - which shouldn't be the case for HTML document context
ref. https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName#value

I leave it to you @capricorn86 - maybe you could add the change in your DOM Parsing PR #1666

close #1151

Comment on lines 233 to 234
// TODO: svg element should return an uppercase SVG tag in html document context
// ref. https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName#value
Copy link
Owner

@capricorn86 capricorn86 Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: svg element should return an uppercase SVG tag in html document context
// ref. https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName#value

SVG elements in the SVG namespace should actually be in lower case (as it is in an XML namespace).

This can easily be tested in the browser:

     var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
     
     document.body.appendChild(svg);
     
     // Outputs "svg"
     console.log(svg.tagName);

@capricorn86
Copy link
Owner

Thank you for your contribution @karpiuMG

I found a small thing.

Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a performance fix and removed the comment 🙂

@capricorn86 capricorn86 merged commit a5424a8 into capricorn86:master Mar 6, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

svg element innertText is undefined
2 participants