silk-gui
Version:
GUI for developers and Node OS
32 lines (26 loc) • 585 B
JavaScript
// xlink
var xlinkNS = 'http://www.w3.org/1999/xlink'
var xlinkRE = /^xlink:/
module.exports = {
priority: 850,
bind: function () {
var name = this.arg
this.update = xlinkRE.test(name)
? xlinkHandler
: defaultHandler
}
}
function defaultHandler (value) {
if (value || value === 0) {
this.el.setAttribute(this.arg, value)
} else {
this.el.removeAttribute(this.arg)
}
}
function xlinkHandler (value) {
if (value != null) {
this.el.setAttributeNS(xlinkNS, this.arg, value)
} else {
this.el.removeAttributeNS(xlinkNS, 'href')
}
}