Skip to content

.className can't be used to set classes on SVG elements #1224

@Conduitry

Description

@Conduitry

Via sveltejs/v2.svelte.dev#216

As of Svelte 1.57.0 we are using classes to scope styles instead of attributes, and SVG DOM elements do not implement a className setter, so trying to set that throws an exception. Classes are allowed on SVG elements, but they can't be programmatically set that way.

I see that when classes are used on SVG elements normally, the generated code uses setAttribute, and so we should probably make sure we use that for CSS scope classes as well.

I'm not sure why this didn't show up in unit tests. Either there aren't any unit tests have scoped CSS and SVG or (more worrisome) jsdom erroneously supports .className setting on SVG elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions