Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler breaks when compiling an input element #63

Closed
seriousManual opened this issue Nov 30, 2016 · 3 comments · Fixed by #71
Closed

compiler breaks when compiling an input element #63

seriousManual opened this issue Nov 30, 2016 · 3 comments · Fixed by #71
Labels

Comments

@seriousManual
Copy link

seriousManual commented Nov 30, 2016

svelte-cli version 1.0.2

consider the following template:

<input type="text" value="">

when compiling via

svelte compile --format iife helloWorld.html > helloWorld.js

the compiler crashes:

mer@ALANIS:/mnt/d/programming/sveltetest$ svelte compile --format iife helloWorld.html > helloWorld.js
compiling helloWorld.html...
/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:6844
                                const value = ( attribute.value[0].type === 'Text' ? '' : `"" + ` ) + (
                                                                  ^

TypeError: Cannot read property 'type' of undefined
    at node.attributes.forEach.attribute (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:6844:39)
    at Array.forEach (native)
    at addElementAttributes (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:6772:18)
    at Object.enter (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:7034:4)
    at visit (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:7512:33)
    at Array.forEach (native)
    at generate (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:7605:23)
    at Object.compile (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/node_modules/svelte/dist/svelte.js:7907:9)
    at compileFile (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/bin.js:611:26)
    at compile$1 (/home/mer/.nvm/versions/node/v6.3.1/lib/node_modules/svelte-cli/bin.js:576:3)
mer@ALANIS:/mnt/d/programming/sveltetest$

UPDATE:
the compiler does not crash when an additional placeholder for the value attribute is used:

<input type="text" value="{{foo}}">
@Rich-Harris
Copy link
Member

Thanks, will fix. Workaround in the meantime is to omit the empty attribute altogether

Rich-Harris added a commit that referenced this issue Nov 30, 2016
handle empty attributes in elements and components
@Rich-Harris
Copy link
Member

Fixed in 1.0.4

@seriousManual
Copy link
Author

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants