Skip to content

Commit 9969614

Browse files
committed
fix: Analysis serialization had incorrect source locations.
1 parent b498968 commit 9969614

File tree

3 files changed

+51
-49
lines changed

3 files changed

+51
-49
lines changed

packages/@css-blocks/core/src/Analyzer/ElementAnalysis.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
727727
serialization.sourceLocation = {
728728
start: { line: this.sourceLocation.start.line },
729729
};
730-
if (this.sourceLocation.start.column) {
730+
if (typeof this.sourceLocation.start.column === "number") {
731731
serialization.sourceLocation.start.column = this.sourceLocation.start.column;
732732
}
733733
if (this.sourceLocation.start.filename) {
@@ -737,7 +737,7 @@ export class ElementAnalysis<BooleanExpression, StringExpression, TernaryExpress
737737
serialization.sourceLocation.end = {
738738
line: this.sourceLocation.end.line,
739739
};
740-
if (this.sourceLocation.end.column) {
740+
if (typeof this.sourceLocation.end.column === "number") {
741741
serialization.sourceLocation.end.column = this.sourceLocation.end.column;
742742
}
743743
if (this.sourceLocation.end.filename) {

packages/@css-blocks/glimmer/src/ElementAnalyzer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
147147
}
148148
}
149149

150-
private finishElement(element: TemplateElement, forRewrite: boolean): void {
150+
private finishElement(node: AnalyzableNode, element: TemplateElement, forRewrite: boolean): void {
151151
element.seal();
152-
if (!forRewrite) { this.analysis.endElement(element); }
152+
if (!forRewrite) { this.analysis.endElement(element, node.loc.end); }
153153
}
154154

155155
isAttributeAnalyzed(attributeName: string): [string, string] | [null, null] {
@@ -269,7 +269,7 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
269269
}
270270
}
271271

272-
this.finishElement(element, forRewrite);
272+
this.finishElement(node, element, forRewrite);
273273

274274
// If this is an Ember Built-In...
275275
if (!isElementNode(node) && isEmberBuiltInNode(node)) {
@@ -294,7 +294,7 @@ export class ElementAnalyzer<TemplateType extends keyof TemplateTypes> {
294294
element.addStaticAttr(style, attr.presenceRule);
295295
}
296296
if (element) {
297-
this.finishElement(element, forRewrite);
297+
this.finishElement(node, element, forRewrite);
298298
}
299299
}
300300
}

0 commit comments

Comments
 (0)