Skip to content

Commit

Permalink
Add xlinkHref property to SurgicalElement
Browse files Browse the repository at this point in the history
Add updateElementAttributeNS
Bump version to 0.5.3
  • Loading branch information
syranide committed May 16, 2018
1 parent 3446e2f commit ee2dfa3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion npm-build/surgical/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "surgical",
"version": "0.5.2",
"version": "0.5.3",
"license": "MIT",
"description": "Surgical is a declarative JavaScript library with native DOM flexibility and performance, for building fast UIs.",
"author": "Andreas Svensson <[email protected]>",
Expand Down
3 changes: 3 additions & 0 deletions packages/surgical/SurgicalElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SurgicalBaseElement from './SurgicalBaseElement';
import updateElementAttribute from './core/updateElementAttribute';
import updateElementAttributeNS from './core/updateElementAttributeNS';
import updateElementAttributes from './core/updateElementAttributes';
import updateElementProxyEventListeners from './core/updateElementProxyEventListeners';
import updateStyleProperties from './core/updateStyleProperties';
Expand All @@ -14,6 +15,7 @@ export default class SurgicalElement extends SurgicalBaseElement {
this.nodeStyle = node.style;

updateElementAttribute(node, 'class', props.className, null);
updateElementAttributeNS(node, 'http://www.w3.org/1999/xlink', 'xlink:href', props.xlinkHref, null);
updateElementAttributes(node, props.attributes, null);
updateStyleProperties(this.nodeStyle, props.style, null);
this.eventListenersInstance = updateElementProxyEventListeners(node, null, props.listeners, null);
Expand All @@ -30,6 +32,7 @@ export default class SurgicalElement extends SurgicalBaseElement {
//}

updateElementAttribute(node, 'class', nextProps.className, lastProps.className);
updateElementAttributeNS(node, 'http://www.w3.org/1999/xlink', 'xlink:href', nextProps.xlinkHref, lastProps.xlinkHref);
updateElementAttributes(node, nextProps.attributes, lastProps.attributes);
updateStyleProperties(this.nodeStyle, nextProps.style, lastProps.style);
this.eventListenersInstance = updateElementProxyEventListeners(node, this.eventListenersInstance, nextProps.listeners, lastProps.listeners);
Expand Down
9 changes: 9 additions & 0 deletions packages/surgical/core/updateElementAttributeNS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function updateElementAttributeNS(node, namespaceURI, name, nextValue, lastValue) {
if (nextValue !== lastValue) {
if (nextValue != null && nextValue !== false) {
node.setAttributeNS(namespaceURI, name, (nextValue === true ? '' : nextValue));
} else if (lastValue != null && lastValue !== false) {
node.removeAttributeNS(namespaceURI, name);
}
}
}

0 comments on commit ee2dfa3

Please sign in to comment.