fix each block sourcemap hack

pull/3539/head
Richard Harris 6 years ago
parent f3064f13f2
commit 37bac60313

@ -107,14 +107,14 @@ export default class EachBlockWrapper extends Wrapper {
// is easy to find // is easy to find
let c = this.node.start + 2; let c = this.node.start + 2;
while (renderer.component.source[c] !== 'e') c += 1; 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 = { const length = {
type: 'Identifier', type: 'Identifier',
name: 'length', name: 'length',
// TODO this format may be incorrect loc: { start, end }
start: c,
end: c + 4
}; };
// renderer.component.code.overwrite(c, c + 4, 'length');
const each_block_value = renderer.component.get_unique_name(`${this.var.name}_value`); const each_block_value = renderer.component.get_unique_name(`${this.var.name}_value`);
const iterations = block.get_unique_name(`${this.var.name}_blocks`); const iterations = block.get_unique_name(`${this.var.name}_blocks`);

@ -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 startIndex = code.indexOf('create_main_fragment');
const expected = locateInSource('each'); const expected = locateInSource('each');
const start = locateInGenerated('length', startIndex ); const start = locateInGenerated('length', startIndex);
const actual = smc.originalPositionFor({ const actual = smc.originalPositionFor({
line: start.line + 1, line: start.line + 1,
column: start.column column: start.column
}); });
assert.deepEqual( actual, { assert.deepEqual(actual, {
source: 'input.svelte', source: 'input.svelte',
name: null, name: null,
line: expected.line + 1, line: expected.line + 1,

Loading…
Cancel
Save