Skip to content

Commit

Permalink
fix: reorder check for special attrs (#2528)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuLaValva authored Feb 20, 2025
1 parent f56fb10 commit 136bb14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-turkeys-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"marko": patch
---

Fix special attrs
25 changes: 12 additions & 13 deletions packages/runtime-class/src/runtime/vdom/VElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,22 @@ VElement.___morphAttrs = function (fromEl, vFromEl, toEl) {
// them to the value in the old map. However, if the value is
// null/undefined/false then we want to remove the attribute
for (attrName in attrs) {
if (
!preserve[attrName] &&
normalizeValue(oldAttrs[attrName]) !==
(attrValue = normalizeValue(attrs[attrName]))
) {
if (!preserve[attrName]) {
attrValue = normalizeValue(attrs[attrName]);
if ((specialAttr = specialAttrs[attrName])) {
specialAttr(fromEl, attrValue);
} else if (attrName === ATTR_XLINK_HREF) {
if (attrValue === undefined) {
fromEl.removeAttributeNS(NS_XLINK, ATTR_HREF);
} else if (normalizeValue(oldAttrs[attrName]) !== attrValue) {
if (attrName === ATTR_XLINK_HREF) {
if (attrValue === undefined) {
fromEl.removeAttributeNS(NS_XLINK, ATTR_HREF);
} else {
fromEl.setAttributeNS(NS_XLINK, ATTR_HREF, attrValue);
}
} else if (attrValue === undefined) {
fromEl.removeAttribute(attrName);
} else {
fromEl.setAttributeNS(NS_XLINK, ATTR_HREF, attrValue);
fromEl.setAttribute(attrName, attrValue);
}
} else if (attrValue === undefined) {
fromEl.removeAttribute(attrName);
} else {
fromEl.setAttribute(attrName, attrValue);
}
}
}
Expand Down

0 comments on commit 136bb14

Please sign in to comment.