lwc icon indicating copy to clipboard operation
lwc copied to clipboard

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

Open nolanlawson opened this issue 10 months ago • 3 comments

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:

https://github.com/salesforce/lwc/blob/8111f1f4b758025ee7c9e54e28721d4e8637ab40/packages/%40lwc/engine-dom/src/renderer/index.ts#L84

...called from here:

https://github.com/salesforce/lwc/blob/8111f1f4b758025ee7c9e54e28721d4e8637ab40/packages/%40lwc/engine-core/src/framework/modules/attrs.ts#L55-L57

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

Repro

nolanlawson avatar Oct 05 '23 22:10 nolanlawson

This issue has been linked to a new work item: W-14246830

git2gus[bot] avatar Oct 05 '23 22:10 git2gus[bot]

This is apparently not a regression; it repros in 2.41.4 (244) as well.

nolanlawson avatar Oct 05 '23 22:10 nolanlawson

Error is thrown in Chrome, Firefox, and Safari.

nolanlawson avatar Oct 05 '23 22:10 nolanlawson