diff --git a/lib/mixins/properties-changed.js b/lib/mixins/properties-changed.js
index 94147a436c..b81844b828 100644
--- a/lib/mixins/properties-changed.js
+++ b/lib/mixins/properties-changed.js
@@ -497,12 +497,12 @@ export const PropertiesChanged = dedupingMixin(
*/
_valueToNodeAttribute(node, value, attribute) {
const str = this._serializeValue(value);
+ if (attribute === 'class' || attribute === 'name' || attribute === 'slot') {
+ node = /** @type {?Element} */(wrap(node));
+ }
if (str === undefined) {
node.removeAttribute(attribute);
} else {
- if (attribute === 'class' || attribute === 'name' || attribute === 'slot') {
- node = /** @type {?Element} */(wrap(node));
- }
node.setAttribute(attribute, str);
}
}
diff --git a/test/unit/styling-scoped.html b/test/unit/styling-scoped.html
index d3a429006b..696cab84bf 100644
--- a/test/unit/styling-scoped.html
+++ b/test/unit/styling-scoped.html
@@ -729,6 +729,31 @@
+
+