0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

fix escaping of sigils in component attribute values in SSR

This commit is contained in:
Conduitry 2018-02-09 01:07:12 -05:00
parent 0ef8229077
commit 132901bbe7
4 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import { AppendTarget } from '../interfaces';
import { Node } from '../../../interfaces';
import getObject from '../../../utils/getObject';
import getTailSnippet from '../../../utils/getTailSnippet';
import { stringify } from '../../../utils/stringify';
import { escape, stringify } from '../../../utils/stringify';
export default function visitComponent(
generator: SsrGenerator,
@ -14,7 +14,7 @@ export default function visitComponent(
node: Node
) {
function stringifyAttribute(chunk: Node) {
if (chunk.type === 'Text') return chunk.data;
if (chunk.type === 'Text') return escape(chunk.data);
if (chunk.type === 'MustacheTag') {
block.contextualise(chunk.expression);
const { snippet } = chunk.metadata;

View File

@ -0,0 +1 @@
<div>{{value}}</div>

View File

@ -0,0 +1,4 @@
export default {
data: { foo: 'foo' },
html: `<div>foo @ foo # foo</div>`,
};

View File

@ -0,0 +1,6 @@
<Widget value='foo @ {{foo}} # foo'/>
<script>
import Widget from './Widget.html';
export default { components: { Widget } };
</script>