Skip to content

DOMException: Failed to execute 'setAttributeNS' on 'Element' on <svg xmlns:xlink> #3779

Open
@nolanlawson

Description

@nolanlawson

Description

<svg>s with the xmlns:xlink attribute cause a runtime error that only occurs with dynamic VNodes (not static ones).

Steps to Reproduce

<template>
    <svg
        data-dynamic={foo}
        xmlns:xlink="http://www.w3.org/1999/xlink"
    ></svg>
</template>

Result

Uncaught DOMException: Failed to execute 'setAttributeNS' on 'Element': 'http://www.w3.org/1999/xlink' is an invalid namespace for attributes.

The error is thrown from LWC here:

: element.setAttributeNS(namespace, name, value);

...called from here:

} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
// Assume xlink namespace
setAttribute(elm, key, cur as string, XLINK_NAMESPACE);

If you remove data-dynamic={foo} above, it will render correctly.

Repro

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions