Skip to content

Commit

Permalink
fix: Analysis serialization had incorrect source locations.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed May 7, 2020
1 parent b498968 commit 9969614
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 49 deletions.
4 changes: 2 additions & 2 deletions packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts
Expand Up @@ -727,7 +727,7 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
serialization.sourceLocation = {
start: { line: this.sourceLocation.start.line },
};
if (this.sourceLocation.start.column) {
if (typeof this.sourceLocation.start.column === "number") {
serialization.sourceLocation.start.column = this.sourceLocation.start.column;
}
if (this.sourceLocation.start.filename) {
Expand All @@ -737,7 +737,7 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
serialization.sourceLocation.end = {
line: this.sourceLocation.end.line,
};
if (this.sourceLocation.end.column) {
if (typeof this.sourceLocation.end.column === "number") {
serialization.sourceLocation.end.column = this.sourceLocation.end.column;
}
if (this.sourceLocation.end.filename) {
Expand Down
8 changes: 4 additions & 4 deletions packages/@css-blocks/glimmer/src/ElementAnalyzer.ts
Expand Up @@ -147,9 +147,9 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
}
}

private finishElement(element: TemplateElement, forRewrite: boolean): void {
private finishElement(node: AnalyzableNode, element: TemplateElement, forRewrite: boolean): void {
element.seal();
if (!forRewrite) { this.analysis.endElement(element); }
if (!forRewrite) { this.analysis.endElement(element, node.loc.end); }
}

isAttributeAnalyzed(attributeName: string): [string, string] | [null, null] {
Expand Down Expand Up @@ -269,7 +269,7 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
}
}

this.finishElement(element, forRewrite);
this.finishElement(node, element, forRewrite);

// If this is an Ember Built-In...
if (!isElementNode(node) && isEmberBuiltInNode(node)) {
Expand All @@ -294,7 +294,7 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
element.addStaticAttr(style, attr.presenceRule);
}
if (element) {
this.finishElement(element, forRewrite);
this.finishElement(node, element, forRewrite);
}
}
}
Expand Down

0 comments on commit 9969614

Please sign in to comment.