UNPKG

assetgraph

Version:

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

24 lines (19 loc) 637 B
const HtmlRelation = require('./HtmlRelation'); class HtmlEdgeSideIncludeSafeComment extends HtmlRelation { inlineHtmlRelation() { let text = this.to.text; const matchText = this.to.text.match( /<!--ASSETGRAPH DOCUMENT START MARKER-->([\s\S]*)<!--ASSETGRAPH DOCUMENT END MARKER-->/ ); if (matchText) { text = matchText[1]; } this.node.nodeValue = `esi ${text}`; this.from.markDirty(); } attach(position, adjacentRelation) { this.node = this.from.parseTree.createComment(''); return super.attach(position, adjacentRelation); } } module.exports = HtmlEdgeSideIncludeSafeComment;