Skip to content

Commit

Permalink
Inline setProperty function (#1122)
Browse files Browse the repository at this point in the history
Saves 7 bytes.
  • Loading branch information
andrewiggins authored and marvinhagemeister committed May 27, 2018
1 parent fd62f6a commit 1b898e2
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/dom/index.js
Expand Up @@ -80,7 +80,11 @@ export function setAccessor(node, name, old, value, isSvg) {
(node._listeners || (node._listeners = {}))[name] = value;
}
else if (name!=='list' && name!=='type' && !isSvg && name in node) {
setProperty(node, name, value==null ? '' : value);
// Attempt to set a DOM property to the given value.
// IE & FF throw for certain property-value combinations.
try {
node[name] = value==null ? '' : value;
} catch (e) { }
if ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);
}
else {
Expand All @@ -100,17 +104,6 @@ export function setAccessor(node, name, old, value, isSvg) {
}


/**
* Attempt to set a DOM property to the given value.
* IE & FF throw for certain property-value combinations.
*/
function setProperty(node, name, value) {
try {
node[name] = value;
} catch (e) { }
}


/**
* Proxy an event to hooked event handlers
* @private
Expand Down

0 comments on commit 1b898e2

Please sign in to comment.