Skip to content

Handle className correctly for SVG nodes #1264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/browser/ui/dom/DefaultDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,29 @@ var DefaultDOMPropertyConfig = {
spellCheck: 'spellcheck',
srcDoc: 'srcdoc',
srcSet: 'srcset'
},
DOMMutationMethods: {
/**
* Setting `className` to null may cause it to be set to the string "null".
*
* @param {DOMElement} node
* @param {*} value
*/
className: function (node, value) {
// The className property of SVG elements is not a string but an
// "SVGAnimatedString" object and can't be written directly.
// if the property is a string, we write the property.
if (typeof node.className === 'string') {
node.className = value != null ? value : '';
} else {
// If not, fall back to using setAttribute.
if (value != null) {
node.setAttribute('class', value);
} else {
node.removeAttribute('class');
}
}
}
}
};

Expand Down