|
|
|
|
@ -26,6 +26,7 @@ import { binding_properties } from '../../bindings.js';
|
|
|
|
|
import { regex_starts_with_newline, regex_whitespaces_strict } from '../../patterns.js';
|
|
|
|
|
import { remove_types } from '../typescript.js';
|
|
|
|
|
import { DOMBooleanAttributes } from '../../../../constants.js';
|
|
|
|
|
import { sanitize_template_string } from '../../../utils/sanitize_template_string.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} value
|
|
|
|
|
@ -117,14 +118,6 @@ function serialize_template(template, out = b.id('out')) {
|
|
|
|
|
return statements;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} str
|
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
function sanitize_template_string(str) {
|
|
|
|
|
return str.replace(/(`|\${|\\)/g, '\\$1');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Processes an array of template nodes, joining sibling text/expression nodes and
|
|
|
|
|
* recursing into child nodes.
|
|
|
|
|
@ -194,7 +187,7 @@ function process_children(nodes, parent, { visit, state }) {
|
|
|
|
|
const node = sequence[i];
|
|
|
|
|
if (node.type === 'Text' || node.type === 'Comment') {
|
|
|
|
|
let last = /** @type {import('estree').TemplateElement} */ (quasis.at(-1));
|
|
|
|
|
last.value.raw += node.type === 'Comment' ? `<!--${node.data}-->` : escape_html(node.data);
|
|
|
|
|
last.value.raw += node.type === 'Comment' ? `<!--${node.data}-->` : sanitize_template_string(escape_html(node.data));
|
|
|
|
|
} else if (node.type === 'Anchor') {
|
|
|
|
|
expressions.push(node.id);
|
|
|
|
|
quasis.push(b.quasi('', i + 1 === sequence.length));
|
|
|
|
|
|