return _hoisted_1
}"
`;
+
+exports[`stringify static html > stringify v-text with escape 1`] = `
+"const { createElementVNode: _createElementVNode, createStaticVNode: _createStaticVNode } = Vue
+
+const _hoisted_1 = /*#__PURE__*/_createStaticVNode(\\"<pre data-type=\\\\\\"js\\\\\\"><code>text1</code></pre><div class><span class>1</span><span class>2</span></div>\\", 2)
+
+return function render(_ctx, _cache) {
+ return _hoisted_1
+}"
+`;
expect(code).toMatch(`<code><span>show-it </span></code>`)
expect(code).toMatchSnapshot()
})
+
+ test('stringify v-text with escape', () => {
+ const { code } = compileWithStringify(`
+ <pre data-type="js"><code v-text="
+ \`text1\`"></code></pre>
+ <div class>
+ <span class>1</span><span class>2</span>
+ </div>`)
+ expect(code).toMatch(`<code>text1</code>`)
+ expect(code).toMatchSnapshot()
+ })
})
// (see compiler-core/src/transforms/transformExpression)
function evaluateConstant(exp: ExpressionNode): string {
if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
- return new Function(`return ${exp.content}`)()
+ return new Function(`return (${exp.content})`)()
} else {
// compound
let res = ``