assetgraph
Version:
An auto discovery dependency graph based optimization framework for web pages and applications
31 lines (26 loc) • 682 B
JavaScript
const SvgRelation = require('./SvgRelation');
class SvgAnchor extends SvgRelation {
get href() {
if (this.isXlink) {
return this.node.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
} else {
return this.node.getAttribute('href');
}
}
set href(href) {
if (this.isXlink) {
this.node.setAttributeNS(
'http://www.w3.org/1999/xlink',
'xlink:href',
href
);
} else {
this.node.setAttribute('href', href);
}
}
attach(position, adjacentRelation) {
this.node = this.from.parseTree.createElement('a');
return super.attach(position, adjacentRelation);
}
}
module.exports = SvgAnchor;