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

SVG element attributes get mangled after build #5578

Closed
ransagy opened this issue Aug 15, 2018 · 2 comments
Closed

SVG element attributes get mangled after build #5578

ransagy opened this issue Aug 15, 2018 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-svg ✔️ Resolution: Duplicate Resolved as a duplicate of another issue help wanted Up for grabs. We would accept a PR to help resolve this issue Status: Resolved
Milestone

Comments

@ransagy
Copy link

ransagy commented Aug 15, 2018

In one of my components, I have a simple inline SVG with a path in it:

<svg class="notif-icon" viewBox="0 0 24 24" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z" />
</svg>

Notice the casing on viewBox and preserveAspectRatio.
After building and running the page containing said component, The result looks like this:

<svg class="notif-icon" viewbox="0 0 24 24" preserveaspectratio="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"></path>
</svg>

The CSS on that element, if that matters:

.notif-icon {
    fill: white;
    width: 36px;
    margin-left: 10px;
    cursor: pointer;
}

The casing on the attributes got flattened to lower-case in the process. At least in Firefox 61 and Chrome 68, This produces an invalid result. Applying any edit to the element in respective browser's devtools or simply correcting the casing produces the expected result.

@SQL-MisterMagoo
Copy link
Contributor

I found this problem only occurred if I was binding properties in the SVG to variables in my code.
If I just have plain svg on the page, it does not mangle the attributes.

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. area-blazor Includes: Blazor, Razor Components help wanted Up for grabs. We would accept a PR to help resolve this issue labels Dec 17, 2018
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, 5.0.0-preview2 Jan 23, 2020
@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label May 14, 2020
@ghost ghost added the Status: Resolved label May 14, 2020
@mkArtakMSFT
Copy link
Member

Closing as we will be tackling this as part of #18271

@ghost ghost locked as resolved and limited conversation to collaborators Jun 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-svg ✔️ Resolution: Duplicate Resolved as a duplicate of another issue help wanted Up for grabs. We would accept a PR to help resolve this issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants