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

parcel build & inline JS issue #1231

Closed
tylerlong opened this issue Apr 22, 2018 · 1 comment
Closed

parcel build & inline JS issue #1231

tylerlong opened this issue Apr 22, 2018 · 1 comment
Labels

Comments

@tylerlong
Copy link

tylerlong commented Apr 22, 2018

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

No parcel config

<textarea v-model="input" rows="8" cols="200" onkeydown="if(event.keyCode===9){var v=this.value,s=this.selectionStart,e=this.selectionEnd;this.value=v.substring(0, s)+'\t'+v.substring(e);this.selectionStart=this.selectionEnd=s+1;return false;}"></textarea>

🤔 Expected Behavior

<textarea v-model="input" rows="8" cols="200" onkeydown="if(event.keyCode===9){var v=this.value,s=this.selectionStart,e=this.selectionEnd;this.value=v.substring(0, s)+'\t'+v.substring(e);this.selectionStart=this.selectionEnd=s+1;return false;}"></textarea>

😯 Current Behavior

<textarea v-model="input" rows="8" cols="200" onkeydown="if(9===event.keyCode){var t=this.value,e=this.selectionStart,i=this.selectionEnd;return this.value=t.substring(0,e)+" \t"+t.substring(i),this.selectionStart="this.selectionEnd=e+1,!1}""></textarea>

onkeydown value is escaped incorrectly and code above has syntax error.

💁 Possible Solution

🔦 Context

parcel index.html is OK while parcel build index.html is not.

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 1.7.1
Node 9.11.1
npm/Yarn yarn 1.5.1
Operating System macOS 10.13.4
@mischnic
Copy link
Member

Beautified:

original:

if (event.keyCode === 9) {
    var v = this.value,
        s = this.selectionStart,
        e = this.selectionEnd;
    this.value = v.substring(0, s) + '\t' + v.substring(e);
    this.selectionStart = this.selectionEnd = s + 1;
    return false;
}

output:

if (9 === event.keyCode) {
    var t = this.value,
        e = this.selectionStart,
        i = this.selectionEnd;
    return this.value = t.substring(0, e) + " \t" + t.substring(i), this.selectionStart = "this.selectionEnd=e+1,!1}"

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

No branches or pull requests

3 participants