Open X-Ryl669 opened 5 years ago
Indeed, changing patcher.js:199
to read:
var nls = oldNode.type !== 'TemplateElement' && needsLeadingSpace(lines, oldNode.loc, newLines);
var nts = oldNode.type !== 'TemplateElement' && needsTrailingSpace(lines, oldNode.loc, newLines);
fixes the issue.
Let's say you have this:
If you modify the
TemplateElement
'snode.value.raw
(containing<div id="it_
) to, let's say (<div id="i_
), then recast will print:which is breaking the templated text (notice the extra space). I've debugged this and found out the issue is in
patcher.js:199
whereneedsTrailingSpace
is set to true with aLine
containing (<div id="i_"
). nts is true because the last char of my modification is_
and the next unmodified node is starting with$
.I think this should not be applied for
TemplateElement
node, since inside a template, you must not change the content