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

html-tag.js is using the .raw version of strings; y tho? #5060

Closed
usergenic opened this issue Jan 24, 2018 · 1 comment
Closed

html-tag.js is using the .raw version of strings; y tho? #5060

usergenic opened this issue Jan 24, 2018 · 1 comment
Assignees

Comments

@usergenic
Copy link

usergenic commented Jan 24, 2018

Description

Consider the template string literal assignment from a recently modulized element iron-a11y-announcer:

html`<div aria-live\$="[[mode]]">[[_text]]</div>`

Note the bound attribute aria-live$= is represented here with an escaped \$ instead of just the $. This is because of a naive, but valid, escaping that takes place when the original html file was ported into the javascript templated string literal in polymer-modulizer.

Polymer html-tag.js, however, uses the .raw value of this literal, resulting in its injection of the escaped character into the DOM, giving everyone binding to attributes the following experience with the current modulized code: https://github.com/Polymer/polymer-modulizer/issues/292

Here's the html-tag code:

const rawStrings = strings.raw;

Can we be clear there's a reason for the html() function to use .raw? Because I don't see a case where you'd want javascript-escape sequences to be literally interpreted when injecting HTML. Is this for convenience of embedding JS source in the template? I think it just makes things even harder to escape inside the embedded JS source then too as a consequence...

@usergenic usergenic changed the title html-tag.js is using the .raw version of strings; y html-tag.js is using the .raw version of strings; y tho? Jan 24, 2018
@usergenic usergenic added the 3.x label Jan 24, 2018
@usergenic
Copy link
Author

Also, yeah yeah yeah we could always not escape dollar signs or backticks at all in the modulizer, but...

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

No branches or pull requests

2 participants