fix(compiler-dom): properly stringify v-html/v-text with constant value
fix #5439 close #5445
This commit is contained in:
@@ -32,3 +32,23 @@ return function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createElementBlock(\\"div\\", null, _hoisted_2))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`stringify static html stringify v-html 1`] = `
|
||||
"const { createElementVNode: _createElementVNode, createStaticVNode: _createStaticVNode } = Vue
|
||||
|
||||
const _hoisted_1 = /*#__PURE__*/_createStaticVNode(\\"<pre data-type=\\\\\\"js\\\\\\"><code><span>show-it </span></code></pre><div class><span class>1</span><span class>2</span></div>\\", 2)
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
return _hoisted_1
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`stringify static html stringify v-text 1`] = `
|
||||
"const { createElementVNode: _createElementVNode, createStaticVNode: _createStaticVNode } = Vue
|
||||
|
||||
const _hoisted_1 = /*#__PURE__*/_createStaticVNode(\\"<pre data-type=\\\\\\"js\\\\\\"><code><span>show-it </span></code></pre><div class><span class>1</span><span class>2</span></div>\\", 2)
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
return _hoisted_1
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -433,4 +433,25 @@ describe('stringify static html', () => {
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
// #5439
|
||||
test('stringify v-html', () => {
|
||||
const { code } = compileWithStringify(`
|
||||
<pre data-type="js"><code v-html="'<span>show-it </span>'"></code></pre>
|
||||
<div class>
|
||||
<span class>1</span><span class>2</span>
|
||||
</div>`)
|
||||
expect(code).toMatch(`<code><span>show-it </span></code>`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('stringify v-text', () => {
|
||||
const { code } = compileWithStringify(`
|
||||
<pre data-type="js"><code v-text="'<span>show-it </span>'"></code></pre>
|
||||
<div class>
|
||||
<span class>1</span><span class>2</span>
|
||||
</div>`)
|
||||
expect(code).toMatch(`<code><span>show-it </span></code>`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user