-
-
Notifications
You must be signed in to change notification settings - Fork 427
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
enforce title tag to be the first child inside svg (if it's not there already) #738
Comments
Hello @revelt, same as the other issue, I am OK with it! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I may pick this up as a part of SVGO, but just want to note an edge case that doesn't make this that simple. An SVG may have a Consider the following: <svg viewBox="0 0 256 172" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
<style>
svg path:nth-child(2) {
color: red;
}
</style>
<path d="M112.973416,9.2496789 C105.800602,-3.0832263 87.8689954,-3.0832263 80.6961815,9.2496789 L2.52446046,143.659628 C-4.64826776,155.992961 4.3176211,171.408985 18.6631204,171.408985 L79.688321,171.408985 C73.5584906,166.051862 71.2883417,156.784087 75.9271555,148.832569 L135.130926,47.3479175 L112.973416,9.2496789 Z" fill="currentcolor"/>
<title>Title</title>
</svg> If |
🚀 Feature Proposal
For backwards compatibility with SVG 1.1 (https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title), we must put
<title>
as the first child, no matter the order it originally comes in.Motivation
It would be nice if
svgr
automatically corrected the position of<title>
element, pushing it forward, to be the first child element.Example
svgr
currently doesn't care about the<title>
tag position. Quick adapted placeholder snippet from the GUI web page app:Above, the
<title>
comes in at a wrong position andsvgr
should be able to automatically fix it.Pitch
Why does this feature belong in the SVGR ecosystem?
It's quick, no-brainer improvement to prevent some edge cases. Who's keen to debug different SVG specs anyway?
The text was updated successfully, but these errors were encountered: