diff --git a/src/compiler/compile/render_dom/wrappers/EachBlock.ts b/src/compiler/compile/render_dom/wrappers/EachBlock.ts index c5f6b0766d..33968c762a 100644 --- a/src/compiler/compile/render_dom/wrappers/EachBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/EachBlock.ts @@ -107,14 +107,14 @@ export default class EachBlockWrapper extends Wrapper { // is easy to find let c = this.node.start + 2; while (renderer.component.source[c] !== 'e') c += 1; + const start = renderer.component.locate(c); + start.line += 1; + const end = { line: start.line, column: start.column + 4 }; const length = { type: 'Identifier', name: 'length', - // TODO this format may be incorrect - start: c, - end: c + 4 + loc: { start, end } }; - // renderer.component.code.overwrite(c, c + 4, 'length'); const each_block_value = renderer.component.get_unique_name(`${this.var.name}_value`); const iterations = block.get_unique_name(`${this.var.name}_blocks`); diff --git a/test/sourcemaps/samples/each-block/test.js b/test/sourcemaps/samples/each-block/test.js index 6e9d2d70b0..35479986a5 100644 --- a/test/sourcemaps/samples/each-block/test.js +++ b/test/sourcemaps/samples/each-block/test.js @@ -1,15 +1,15 @@ -export function test({ assert, code, smc, locateInSource, locateInGenerated }) { +export function test({ assert, code, smc, map, locateInSource, locateInGenerated }) { const startIndex = code.indexOf('create_main_fragment'); const expected = locateInSource('each'); - const start = locateInGenerated('length', startIndex ); + const start = locateInGenerated('length', startIndex); const actual = smc.originalPositionFor({ line: start.line + 1, column: start.column }); - assert.deepEqual( actual, { + assert.deepEqual(actual, { source: 'input.svelte', name: null, line: expected.line + 1,