-
Notifications
You must be signed in to change notification settings - Fork 192
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 parsing regression for svg element tag names with camelCase: ReferenceError: radialGradient is not defined
when converting to gts-component
#1550
SVG element parsing regression for svg element tag names with camelCase: ReferenceError: radialGradient is not defined
when converting to gts-component
#1550
Comments
ReferenceError: radialGradient is not defined
when conveting to gts-componentReferenceError: radialGradient is not defined
when converting to gts-component
Do you happen to have what the compiled version of that component looks like? |
@NullVoxPopuli like this? radial-gradient-reproduction.ts: import { template } from "@ember/template-compiler";
const RadialGradientReproduction = template(`
<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<radialGradient id="myGradient">
<stop offset="10%" stop-color="gold" />
<stop offset="95%" stop-color="red" />
</radialGradient>
</defs>
<circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>
`, {
eval () {
return eval(arguments[0]);
}
});
export default RadialGradientReproduction; (how the browser loads the component) |
btw, this seems to be an issue with all svg elements with camelCased tag names, e.g: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateMotion |
ReferenceError: radialGradient is not defined
when converting to gts-componentReferenceError: radialGradient is not defined
when converting to gts-component
This has all the tags we'd want: https://www.npmjs.com/package/html-spec-tags?activeTab=readme |
I ran into this too. I didn't try super hard to break it, so this is not necessarily conclusive, but I added a test to the the strict mode tests and it passes: @test
'camelCased SVG elements are not considered identifiers/references'() {
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
const Foo = defineComponent({}, stripTight`
<svg viewBox="0 0 10 10">
<defs>
<linearGradient id="myGradient">
<stop offset="5%" stop-color="gold" />
<stop offset="95%" stop-color="red" />
</linearGradient>
</defs>
<circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>
`);
this.renderComponent(Foo);
this.assertHTML(stripTight`
<svg viewBox="0 0 10 10">
<defs>
<linearGradient id="myGradient">
<stop offset="5%" stop-color="gold" />
<stop offset="95%" stop-color="red" />
</linearGradient>
</defs>
<circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>
`);
this.assertStableRerender();
} So that matches my suspicion that the problem is not, strictly speaking, in glimmer-vm. I think the problem is likely that babel-plugin-ember-template-compilation is using |
I get a regression when converting a template-only-hbs-component into a template-only-gts-component.
The gts-parser seems to think that the svg element radialGradient is a glimmer component, and not an svg element:
Error in browser console:
Reproduction:
Environment:
The text was updated successfully, but these errors were encountered: