Open
Description
Description
Setting an attribute to a value of null
or undefined
will typically cause a removeAttribute
call in LWC. However, this doesn't work for svg/xml namespace attributes (repro).
Template:
<template>
<div title={prop}></div>
<label xml:lang={prop}></label>
<svg>
<image xlink:title={prop}></image>
</svg>
</template>
Result:
<div></div>
<label xml:lang="null"></label>
<svg>
<image xlink:title="null"></image>
</svg>
Expected result:
<div></div>
<label></label>
<svg>
<image></image>
</svg>
The root cause is these lines of code. Note that svg/xml namespace attributes will never result in a removeAttribute
:
lwc/packages/@lwc/engine-core/src/framework/modules/attrs.ts
Lines 39 to 49 in def03ea
Note that fixing this would be an observable change.
Activity