-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Preserve camelCase for known svg elements #3875
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
base: master
Are you sure you want to change the base?
Conversation
SVG elements like feDropShadow were incorrectly converted to lowercase, breaking their functionality. Now properly preserves casing for known SVG elements while normalizing regular HTML elements. Fixes svg filter rendering issue where filters would not display.
Visit the preview URL for this PR (updated for commit 3ad175b): https://yew-rs-api--pr3875-fix-svg-filter-casin-l2azl722.web.app (expires Sun, 17 Aug 2025 15:21:52 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Benchmark - SSRYew Master
Pull Request
|
Size Comparison
✅ None of the examples has changed their size significantly. |
@WorldSEnder what's your stance on this? I see you worked on #2578 which is related to this issue |
This comment was marked as resolved.
This comment was marked as resolved.
Why does Yew even meddle with the element names? shouldn't it pass them to the browser as they're specified? |
I'm trying to dig through the issues and PRs related to this again. Generally I'm in favor of preserving the casing seen in code going forward instead of normalizing. This would probably move a lot of code that uses dynamic tag names back to literal tags. The central issue is #1269. This comment mentions that browsers seemed to be fine with "wrongly" cased elements in svg at some point. The target seems to have moved and invalid casing is no longer acceptable. Literal tag names are constrained to be valid rust identifiers (stemming from the macro parsing). Which is why we fill the gap between this and browser elements (such as converting underscores to hyphens). Note e.g. that In any case, the original pullrequest in #1266 was aware of all this (although as mentioned above, browsers seem to have gotten more strict). However, it mentions "runtime checks that rely on the casing" and I'm not sure what checks exactly this refers to. I can find some runtime elements relying on the casing of the tag - there might be more:
Given all that, my current stance is that: Lowercasing an element name is only okay if the element is in the HTML namespace. The macro machinery can assume this for additional compile time checks against a blacklist (such as checking void elements or well-known types such as I think that the name getting emitted by the macro should be |
Benchmark - coreYew Master
Pull Request
|
570871e
to
70c7ea7
Compare
|
70c7ea7
to
4fb9f9d
Compare
4fb9f9d
to
f17793f
Compare
Description
This PR fixes SVG filter elements that require camelCase names (like
feDropShadow
) from being incorrectly lowercased, which causes them to not function at all in browsers.SVG filter effects completely stop working when their element names are lowercased:
The browser does not recognize
<fedropshadow>
as a valid SVG filter primitive, so the entire filter effect is ignored.The Fix
This PR modifies the tag name handling to:
is_normalised_element_name
function)This ensures SVG elements work correctly while maintaining the expected behavior for HTML elements.
Example