Fixed slots and props not being added to ctx

Fixed linting error
Removed 'catch after error' test
pull/6585/head
rster20002 5 years ago
parent ba7c38f900
commit fb33f457bd

@ -444,17 +444,25 @@ export default function dom(
const return_value_reference = b`let #return_values = []`;
const return_value = {
type: 'ArrayExpression',
elements: renderer.initial_context.map(member => ({
type: 'Identifier',
name: member.name
}) as Expression)
};
let instance_javascript_with_ctx = [];
const initializedIdentifiers = [];
const add_variable_to_ctx = id => {
const index = renderer.initial_context.findIndex(member => member.name === id.name);
if (index >= 0) {
instance_javascript_with_ctx.push(b`#return_values[${index}] = ${id};`[0]);
initializedIdentifiers.push(id.name);
}
}
const slot_definitions_present = component.slots.size || component.compile_options.dev || uses_slots;
if (slot_definitions_present) {
add_variable_to_ctx({ type: "Identifier", name: "#slots" });
add_variable_to_ctx({ type: "Identifier", name: "$$scope" });
}
if (instance_javascript === null) {
instance_javascript_with_ctx = instance_javascript;
} else {
@ -463,23 +471,17 @@ export default function dom(
if (Array.isArray(node) && node[0].type === 'VariableDeclaration') {
node[0].declarations.forEach(({ id }) => {
const index = renderer.initial_context.findIndex(member => member.name === id.name);
if (index >= 0) {
instance_javascript_with_ctx.push(b`#return_values[${index}] = ${id};`[0]);
initializedIdentifiers.push(id.name);
if (id.type === 'ObjectPattern') {
id.properties.forEach(property => add_variable_to_ctx(property.key));
} else {
add_variable_to_ctx(id);
}
});
}
if (node.type === 'FunctionDeclaration') {
if (!initializedIdentifiers.includes(node.id.name)) {
const index = renderer.initial_context.findIndex(member => member.name === node.id.name);
if (index >= 0) {
instance_javascript_with_ctx.push(b`#return_values[${index}] = ${node.id};`[0]);
initializedIdentifiers.push(node.id.name);
}
add_variable_to_ctx(node.id);
}
}
});
@ -535,7 +537,7 @@ export default function dom(
${rest}
${component.slots.size || component.compile_options.dev || uses_slots ? b`let { $$slots: #slots = {}, $$scope } = $$props;` : null}
${slot_definitions_present ? b`let { $$slots: #slots = {}, $$scope } = $$props;` : null}
${component.compile_options.dev && b`@validate_slots('${component.tag}', #slots, [${[...component.slots.keys()].map(key => `'${key}'`).join(',')}]);`}
${compute_slots}

@ -1,5 +0,0 @@
export default {
test({ assert, component }) {
assert.equal(component.error, true);
}
};

@ -1,12 +0,0 @@
<script>
import { onError } from "svelte";
var a = {};
export var error = false;
a.b.c
onError(e => {
error = true;
});
</script>
Loading…
Cancel
Save