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() {
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 {
component,
declarations,
scope_map: map,
template_scope,
owner
owner,
is_synthetic
} = this;
let scope = this.scope;
@ -221,7 +218,7 @@ export default class Expression {
dependencies.add(name);
component.expectedProperties.add(name);
}
} else {
} else if (!is_synthetic) {
code.prependRight(node.start, key === 'key' && parent.shorthand
? `${name}: ctx.`
: 'ctx.');

@ -263,13 +263,16 @@ export default class InlineComponentWrapper extends Wrapper {
});
const munged_handlers = this.node.handlers.map(handler => {
// TODO return declarations from handler.render()?
const snippet = handler.render();
if (handler.expression) {
handler.expression.declarations.forEach(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') {

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

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

Loading…
Cancel
Save