dont typecast numeric attributes

pull/1348/head
Rich Harris 6 years ago
parent 80e0dceb9a
commit 4fe8d95a6d

@ -55,7 +55,7 @@ export default function mungeAttribute(attribute: Node, block: Block): MungedAtt
return {
spread: false,
name: attribute.name,
value: isNaN(value.data) ? stringify(value.data) : value.data,
value: stringify(value.data),
dynamic: false,
dependencies: []
};

@ -57,7 +57,7 @@ export default function visitComponent(
if (attribute.value.length === 1) {
const chunk = attribute.value[0];
if (chunk.type === 'Text') {
return isNaN(chunk.data) ? stringify(chunk.data) : chunk.data;
return stringify(chunk.data);
}
block.contextualise(chunk.expression);

@ -190,7 +190,7 @@ export function showOutput(cwd, options = {}, compile = svelte.compile) {
.replace(/^\d/, '_$&')
.replace(/[^a-zA-Z0-9_$]/g, '');
const { code } = compile(
const { js } = compile(
fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
Object.assign(options, {
filename: file,
@ -200,7 +200,7 @@ export function showOutput(cwd, options = {}, compile = svelte.compile) {
);
console.log( // eslint-disable-line no-console
`\n>> ${chalk.cyan.bold(file)}\n${addLineNumbers(code)}\n<< ${chalk.cyan.bold(file)}`
`\n>> ${chalk.cyan.bold(file)}\n${addLineNumbers(js.code)}\n<< ${chalk.cyan.bold(file)}`
);
});
}

@ -1,5 +1,5 @@
<div>
<Widget foo='bar' baz='42'/>
<Widget foo='bar' baz={{42}}/>
</div>
<script>

@ -1,4 +1,4 @@
<div>
<p>foo: bar</p>
<p>baz: 42 (number)</p>
<p>baz: 42 (string)</p>
</div>
Loading…
Cancel
Save