Skip to content

Commit bdc427a

Browse files
committed
Handle className correctly for SVG nodes.
1 parent fa154e6 commit bdc427a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/browser/ui/dom/HTMLDOMPropertyConfig.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,29 @@ var HTMLDOMPropertyConfig = {
154154
spellCheck: 'spellcheck',
155155
srcDoc: 'srcdoc',
156156
srcSet: 'srcset'
157+
},
158+
DOMMutationMethods: {
159+
/**
160+
* Setting `className` to null may cause it to be set to the string "null".
161+
*
162+
* @param {DOMElement} node
163+
* @param {*} value
164+
*/
165+
className: function (node, value) {
166+
// The className property of SVG elements is not a string but an
167+
// "SVGAnimatedString" object and can't be written directly.
168+
// if the property is a string, we write the property.
169+
if (typeof node.className === 'string') {
170+
node.className = value != null ? value : '';
171+
} else {
172+
// If not, fall back to using setAttribute.
173+
if (value != null) {
174+
node.setAttribute('class', value);
175+
} else {
176+
node.removeAttribute('class');
177+
}
178+
}
179+
}
157180
}
158181
};
159182

0 commit comments

Comments
 (0)