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

dont typecast numeric attributes

This commit is contained in:
Rich Harris 2018-04-15 20:07:08 -04:00
parent 80e0dceb9a
commit 4fe8d95a6d
5 changed files with 6 additions and 6 deletions

View File

@ -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: []
};

View File

@ -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);

View File

@ -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)}`
);
});
}

View File

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

View File

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