Skip to content

Commit

Permalink
Use javascript string escaping in Polymer.html
Browse files Browse the repository at this point in the history
There's a lot of pitfalls

Fixes #5060
  • Loading branch information
dfreedm committed Jan 25, 2018
1 parent 90199f3 commit 4c66214
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/utils/html-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@
* @return {!HTMLTemplateElement} Constructed HTMLTemplateElement
*/
Polymer.html = function html(strings, ...values) {
// use raw strings to preserve literal escapes in strings
/** @type {!Array<string>} */
const rawStrings = strings.raw;
const template = /** @type {!HTMLTemplateElement} */(document.createElement('template'));
template.innerHTML = values.reduce((acc, v, idx) =>
acc + htmlValue(v) + rawStrings[idx + 1], rawStrings[0]);
acc + htmlValue(v) + strings[idx + 1], strings[0]);
return template;
};
})();
Expand Down

0 comments on commit 4c66214

Please sign in to comment.