With --compilation_level ADVANCED, concatenated template literals are not merged into one.
let url = document.location.href;
console.log(
`<h1>${url}</h1>`
+ `<p>The URL is ${url}.</p>`
);
url = '//example.com/';
console.log(
`<h1>${url}</h1>`
+ `<p>The URL is ${url}.</p>`
);
const other_url = '//example.com/';
console.log(
`<h1>${other_url}</h1>`
+ `<p>The URL is ${other_url}.</p>`
);
Output (with extra line breaks after ;):
let a=document.location.href;
console.log(`<h1>${a}</h1>`+`<p>The URL is ${a}.</p>`);
a="//example.com/";
console.log(`<h1>${a}</h1>`+`<p>The URL is ${a}.</p>`);
console.log("<h1>//example.com/</h1><p>The URL is //example.com/.</p>");
When the values are known, it converts the template string to a normal string and combines them.
I would expect this:
let a=document.location.href;
console.log(`<h1>${a}</h1><p>The URL is ${a}.</p>`);
a="//example.com/";
console.log(`<h1>${a}</h1><p>The URL is ${a}.</p>`);
console.log("<h1>//example.com/</h1><p>The URL is //example.com/.</p>");
Or is there a perhaps a reason not to join the template literals in the first two cases?
With --compilation_level ADVANCED, concatenated template literals are not merged into one.
Output (with extra line breaks after ;):
When the values are known, it converts the template string to a normal string and combines them.
I would expect this:
Or is there a perhaps a reason not to join the template literals in the first two cases?