Fixed added error handling tests

pull/6585/head
rster20002 5 years ago
parent 648c62790d
commit ad2aba861b

@ -404,16 +404,20 @@ export default class Block {
}
});
console.log("H");
this.chunks.init.forEach(node => {
if (Array.isArray(node) && node[0].type === "VariableDeclaration") {
node[0].declarations.forEach(({ id, init }) => {
console.log(id);
init_declarations.push(b`let ${id};`);
init_statements.push(b`${id} = ${init}`);
if (Array.isArray(node)) {
node.forEach((declaration: any) => { // TODO add type to this
if (declaration.declarations) {
declaration.declarations.forEach(({ id, init }) => {
init_declarations.push(b`let ${id}`);
init_statements.push(b`${id} = ${init}`);
});
} else {
init_statements.push(declaration);
}
});
} else {
init_declarations.push(node);
init_statements.push(node);
}
});
@ -428,6 +432,7 @@ export default class Block {
${init_statements}
} catch (e) {
@handle_error(@get_current_component(), e);
return;
}`
: ''
}

@ -453,7 +453,7 @@ export default function dom(
};
let instance_javascript_with_ctx = [];
let initializedIdentifiers = [];
const initializedIdentifiers = [];
if (instance_javascript === null) {
instance_javascript_with_ctx = instance_javascript;
@ -461,11 +461,11 @@ export default function dom(
instance_javascript.forEach(node => {
instance_javascript_with_ctx.push(node);
if (Array.isArray(node) && node[0].type === "VariableDeclaration" ) {
if (Array.isArray(node) && node[0].type === 'VariableDeclaration') {
walk(node[0], {
enter(declaration: Identifier) {
if (declaration.type === 'Identifier' && !initializedIdentifiers.includes(declaration.name)) {
let index = renderer.initial_context.findIndex(member => member.name === declaration.name);
const index = renderer.initial_context.findIndex(member => member.name === declaration.name);
if (index >= 0) {
node.push(x`#return_values[${index}] = ${declaration}`);
@ -476,9 +476,9 @@ export default function dom(
});
}
if (node.type === "FunctionDeclaration") {
if (node.type === 'FunctionDeclaration') {
if (!initializedIdentifiers.includes(node.id.name)) {
let index = renderer.initial_context.findIndex(member => member.name === node.id.name);
const index = renderer.initial_context.findIndex(member => member.name === node.id.name);
if (index >= 0) {
instance_javascript_with_ctx.push(x`#return_values[${index}] = ${node.id.name}`);

@ -203,7 +203,9 @@ export function insert_hydration(target: NodeEx, node: NodeEx, anchor?: NodeEx)
}
export function detach(node: Node) {
node.parentNode.removeChild(node);
if (node.parentNode !== null) {
node.parentNode.removeChild(node);
}
}
export function destroy_each(iterations, detaching) {

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -1,20 +1,14 @@
<script>
import { onError } from "svelte";
var a = [1, 2, 3];
var a = {}
export var error = false;
onError(e => {
error = true;
});
function handleClick() {
a = 10;
}
</script>
{#each a as item}
{#each a.b.c as item}
{item}
{/each}
<button on:click={handleClick}></button>
{/each}

@ -7,4 +7,4 @@ export default {
assert.equal(component.error, true);
}
}
};

@ -1,14 +1,20 @@
<script>
import { onError } from "svelte";
var a = {}
var a = [1, 2, 3];
export var error = false;
onError(e => {
error = true;
});
function handleClick() {
a = 10;
}
</script>
{#each a.b.c as item}
{#each a as item}
{item}
{/each}
{/each}
<button on:click={handleClick}></button>

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -8,4 +8,4 @@ export default {
assert.equal(component.error, true);
assert.equal(component.that, button);
}
}
};

@ -7,4 +7,4 @@ export default {
assert.equal(component.error, true);
}
}
};

@ -7,4 +7,4 @@ export default {
assert.equal(component.error, true);
}
}
};

@ -7,4 +7,4 @@ export default {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

@ -7,4 +7,4 @@ export default {
assert.equal(component.error, true);
}
}
};

@ -2,4 +2,4 @@ export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
}
};

Loading…
Cancel
Save