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

html! macro changes the case of SVG tags. #2699

Closed
1 task done
wainwrightmark opened this issue May 23, 2022 · 3 comments · Fixed by #2703
Closed
1 task done

html! macro changes the case of SVG tags. #2699

wainwrightmark opened this issue May 23, 2022 · 3 comments · Fixed by #2703

Comments

@wainwrightmark
Copy link
Contributor

Problem
SVG tags are case sensitive and some of them (e.g. feGaussianBlur use camelCase. The html! macro seems to be changing all tag names to lower case which prevents the elements from being rendered.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Create a new yew app (https://yew.rs/docs/tutorial)
  2. Replace the html! block with the following (from https://yew.rs/docs/next/concepts/html#children)
html! {
    <svg width="149" height="147" viewBox="0 0 149 147" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M60.5776 13.8268L51.8673 42.6431L77.7475 37.331L60.5776 13.8268Z" fill="#DEB819"/>
        <path d="M108.361 94.9937L138.708 90.686L115.342 69.8642" stroke="black" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
        <g filter="url(#filter0_d)">
            <circle cx="75.3326" cy="73.4918" r="55" fill="#FDD630"/>
            <circle cx="75.3326" cy="73.4918" r="52.5" stroke="black" stroke-width="5"/>
        </g>
        <circle cx="71" cy="99" r="5" fill="white" fill-opacity="0.75" stroke="black" stroke-width="3"/>
        <defs>
            <filter id="filter0_d" x="16.3326" y="18.4918" width="118" height="118" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
                <feGaussianBlur stdDeviation="2"/>
                <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
            </filter>
        </defs>
    </svg>
}
  1. trunk serve --open
  2. Use browser inspector to look at the feGaussianBlur element.

Expected behavior
The feGaussianBlur element should have the correct casing. Instead it is all lower case.

Environment:

  • Yew version: 0.19
  • Rust version: 1.61.0
  • Target, if relevant: wasm32-unknown-unknown
  • Build tool, if relevant: trunk
  • OS, if relevant: Windows
  • Browser and version, if relevant: Chrome latest, Firefox latest

Questionnaire

  • I'm interested in fixing this myself but don't know where to start

Workaround

I've managed to work around this by using a dynamic tag name @{"feGaussianBlur"} but this only worked with yew = { git = "https://github.com/yewstack/yew.git"}, not with version 0.19.

I'm not sure what the solution to this problem is as changing the casing rules seems like a huge breaking change, but I think the documentation should at least make the situation clear rather than having a broken example.

By the way, I really enjoy using Yew and, apart from this issue, it's been brilliant!

@WorldSEnder
Copy link
Member

WorldSEnder commented May 23, 2022

Functionally a duplicate of #2483. I suppose we could try to back-port #2578 to 0.19 if you need it?

I'll add the documentation tag to address that part.

@wainwrightmark
Copy link
Contributor Author

Oh, so sorry. I should have searched closed issues.
No need to backport it for me. I've just tried nightly Rust and seen the lint so that's good.

I'm happy to submit a PR for the documentation. The only question is what to suggest for 0.19 users. Should they just switch to Next if they need this?

@WorldSEnder
Copy link
Member

WorldSEnder commented May 24, 2022

One possible workaround for 0.19 users is to forgo the html! macro and use the VTag::new constructor directly, add attributes and children "by hand". That one should preserve casing, though at the expense of some convenience.

And a documentation PR would be appreciated. We're using docusaurus and versioned docs, so you can add a warning or note to the 0.19 docs and different text to the current ones. Feel free to start with a draft PR and ask if you get stuck anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants