|
|
|
|
@ -3,7 +3,6 @@ import { x } from 'code-red';
|
|
|
|
|
|
|
|
|
|
/** @extends Wrapper */
|
|
|
|
|
export default class CommentWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
/** @type {import('../../nodes/Comment.js').default} */
|
|
|
|
|
node;
|
|
|
|
|
|
|
|
|
|
@ -27,8 +26,7 @@ export default class CommentWrapper extends Wrapper {
|
|
|
|
|
* @param {import('estree').Identifier} parent_nodes
|
|
|
|
|
*/
|
|
|
|
|
render(block, parent_node, parent_nodes) {
|
|
|
|
|
if (!this.renderer.options.preserveComments)
|
|
|
|
|
return;
|
|
|
|
|
if (!this.renderer.options.preserveComments) return;
|
|
|
|
|
const string_literal = {
|
|
|
|
|
type: 'Literal',
|
|
|
|
|
value: this.node.data,
|
|
|
|
|
@ -37,15 +35,15 @@ export default class CommentWrapper extends Wrapper {
|
|
|
|
|
end: this.renderer.locate(this.node.end)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
block.add_element(this.var, x `@comment(${string_literal})`, parent_nodes && x `@claim_comment(${parent_nodes}, ${string_literal})`, parent_node);
|
|
|
|
|
block.add_element(
|
|
|
|
|
this.var,
|
|
|
|
|
x`@comment(${string_literal})`,
|
|
|
|
|
parent_nodes && x`@claim_comment(${parent_nodes}, ${string_literal})`,
|
|
|
|
|
parent_node
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
text() {
|
|
|
|
|
if (!this.renderer.options.preserveComments)
|
|
|
|
|
return '';
|
|
|
|
|
if (!this.renderer.options.preserveComments) return '';
|
|
|
|
|
return `<!--${this.node.data}-->`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|