UNPKG

assetgraph

Version:

An auto discovery dependency graph based optimization framework for web pages and applications

33 lines (27 loc) 716 B
const SvgRelation = require('./SvgRelation'); class SvgUse 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('use'); return super.attach(position, adjacentRelation); } } SvgUse.prototype.targetType = 'Svg'; module.exports = SvgUse;