-
Notifications
You must be signed in to change notification settings - Fork 235
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
Fix desugared directive #401
Changes from 8 commits
1c163d9
0d90eef
4429088
c1873e9
d824745
19bb0ce
074489f
dcfaf28
c71fac8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,11 +152,21 @@ class WhitespaceTemplateVisitor extends BasicTemplateAstVisitor { | |
|
||
class PipeWhitespaceVisitor extends RecursiveAngularExpressionVisitor implements ConfigurableVisitor { | ||
visitPipe(ast: ast.BindingPipe, context: RecursiveAngularExpressionVisitor): any { | ||
const start = ast.span.start; | ||
const exprStart = context.getSourcePosition(ast.exp.span.start); | ||
const exprEnd = context.getSourcePosition(ast.exp.span.end); | ||
const sf = context.getSourceFile().getFullText(); | ||
const exprText = sf.substring(exprStart, exprEnd); | ||
|
||
let exprStart, exprEnd, exprText, sf; | ||
if (NgWalker.prop && ( NgWalker.prop.templateName === 'ngForOf' || NgWalker.prop.templateName === 'ngIf')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this valid for all different templates? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, a test on |
||
exprStart = context.getSourcePosition(ast.exp.span.start) - (ast.span.start); // t pony of ponies | | ||
exprEnd = context.getSourcePosition(ast.exp.span.end) - (ast.span.start); // - (ast.span.end - ast.span.start); | ||
sf = context.getSourceFile().getFullText(); | ||
exprText = sf.substring(exprStart, exprEnd); | ||
NgWalker.prop = null; | ||
} else { | ||
exprStart = context.getSourcePosition(ast.exp.span.start); | ||
exprEnd = context.getSourcePosition(ast.exp.span.end); | ||
sf = context.getSourceFile().getFullText(); | ||
exprText = sf.substring(exprStart, exprEnd); | ||
} | ||
|
||
const replacements = []; | ||
// Handling the right side of the pipe | ||
let leftBeginning = exprEnd + 1; // exprEnd === '|' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can preserve the context (
prop
) from a parent element visitor?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is an evil way. After a good night, now, we have our context the parent class
sourceMappingVistor
. It's better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, I modified
SourceMappingVisitor.getSourcePosition()
method, which is more central. So, this fix the position problem in our tests.