fix all runtime tests broken by SSR work

pull/1839/head
Rich Harris 7 years ago
parent a23bf00667
commit 72b9254436

@ -170,16 +170,13 @@ export default class Expression {
render() { render() {
if (this.rendered) return this.rendered; if (this.rendered) return this.rendered;
// <option> value attribute could be synthetic — avoid double editing
// TODO move this logic into Element?
if (this.is_synthetic) return;
const { const {
component, component,
declarations, declarations,
scope_map: map, scope_map: map,
template_scope, template_scope,
owner owner,
is_synthetic
} = this; } = this;
let scope = this.scope; let scope = this.scope;
@ -221,7 +218,7 @@ export default class Expression {
dependencies.add(name); dependencies.add(name);
component.expectedProperties.add(name); component.expectedProperties.add(name);
} }
} else { } else if (!is_synthetic) {
code.prependRight(node.start, key === 'key' && parent.shorthand code.prependRight(node.start, key === 'key' && parent.shorthand
? `${name}: ctx.` ? `${name}: ctx.`
: 'ctx.'); : 'ctx.');

@ -263,13 +263,16 @@ export default class InlineComponentWrapper extends Wrapper {
}); });
const munged_handlers = this.node.handlers.map(handler => { const munged_handlers = this.node.handlers.map(handler => {
// TODO return declarations from handler.render()?
const snippet = handler.render();
if (handler.expression) { if (handler.expression) {
handler.expression.declarations.forEach(declaration => { handler.expression.declarations.forEach(declaration => {
block.builders.init.addBlock(declaration); block.builders.init.addBlock(declaration);
}); });
} }
return `${name}.$on("${handler.name}", ${handler.render()});`; return `${name}.$on("${handler.name}", ${snippet});`;
}); });
if (this.node.name === 'svelte:component') { if (this.node.name === 'svelte:component') {

@ -28,7 +28,7 @@ function getName(filename) {
const sveltePath = process.cwd(); const sveltePath = process.cwd();
const internal = path.join(sveltePath, 'internal.js'); const internal = path.join(sveltePath, 'internal.js');
describe.only("runtime", () => { describe("runtime", () => {
before(() => { before(() => {
svelte = loadSvelte(false); svelte = loadSvelte(false);
svelte$ = loadSvelte(true); svelte$ = loadSvelte(true);

@ -21,7 +21,7 @@ function tryToReadFile(file) {
const sveltePath = process.cwd(); const sveltePath = process.cwd();
describe.only("ssr", () => { describe("ssr", () => {
before(() => { before(() => {
require("../../register")({ require("../../register")({
extensions: ['.svelte', '.html'], extensions: ['.svelte', '.html'],

Loading…
Cancel
Save