assetgraph
Version:
An auto discovery dependency graph based optimization framework for web pages and applications
37 lines (30 loc) • 796 B
JavaScript
const Relation = require('./Relation');
class XmlStylesheet extends Relation {
get href() {
const matchData = this.node.data.match(/href="([^"]*)"/);
if (matchData) {
return matchData[1].replace(/"/, '"').replace(/&/, '&');
}
}
set href(href) {
this.node.data = this.node.data.replace(
/href="([^"]*)"/,
`href="${href.replace(/&/g, '&').replace(/"/g, '"')}"`
);
}
inline() {
super.inline();
this.href = this.to.dataUrl + (this.fragment || '');
this.from.markDirty();
return this;
}
attach() {
throw new Error('XmlStylesheet.attach: Not supported');
}
detach() {
this.node.parentNode.removeChild(this.node);
this.node = undefined;
super.detach();
}
}
module.exports = XmlStylesheet;