all tests passing

pull/1367/head
Rich Harris 6 years ago
parent c3c7970dc9
commit 7224ef4eff

@ -89,7 +89,7 @@ export default class Attribute extends Node {
if (chunk.type === 'Text') {
return stringify(chunk.data);
} else {
return getExpressionPrecedence(chunk.node) <= 13 ? `(${chunk.snippet})` : snippet;
return getExpressionPrecedence(chunk.node) <= 13 ? `(${chunk.snippet})` : chunk.snippet;
}
})
.join(' + ');
@ -194,11 +194,13 @@ export default class Attribute extends Node {
const isSelectValueAttribute =
name === 'value' && node.name === 'select';
const last = (shouldCache || isSelectValueAttribute) && block.getUniqueName(
if (isSelectValueAttribute) shouldCache = true;
const last = shouldCache && block.getUniqueName(
`${node.var}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value`
);
if (shouldCache || isSelectValueAttribute) block.addVariable(last);
if (shouldCache) block.addVariable(last);
let updater;
const init = shouldCache ? `${last} = ${value}` : value;

@ -17,6 +17,7 @@ const readOnlyMediaAttributes = new Set([
export default class Binding extends Node {
name: string;
value: Expression;
usesContext: boolean;
obj: string;
prop: string;
@ -33,10 +34,14 @@ export default class Binding extends Node {
prop = `[✂${this.value.node.property.start}-${this.value.node.property.end}✂]`;
if (!this.value.node.computed) prop = `'${prop}'`;
obj = `[✂${this.value.node.object.start}-${this.value.node.object.end}✂]`;
this.usesContext = true;
} else {
const { name } = getObject(this.value.node);
obj = 'ctx';
prop = `'${name}'`;
this.usesContext = scope.names.has(name);
}
this.obj = obj;

@ -320,16 +320,15 @@ export default class Element extends Node {
//(this.hasAncestor('EachBlock') && this.bindings.length > 0) ||
this.handlers.some(handler => handler.shouldHoist)
);
let eventHandlerOrBindingUsesComponent;
let eventHandlerOrBindingUsesContext;
const eventHandlerOrBindingUsesComponent = (
this.bindings.length > 0 ||
this.handlers.some(handler => handler.usesComponent)
);
if (this.bindings.length > 0) {
eventHandlerOrBindingUsesComponent = true;
eventHandlerOrBindingUsesContext = true;
} else {
eventHandlerOrBindingUsesComponent = this.handlers.some(handler => handler.usesComponent);
eventHandlerOrBindingUsesContext = this.handlers.some(handler => handler.usesContext);
}
const eventHandlerOrBindingUsesContext = (
this.bindings.some(binding => binding.usesContext) ||
this.handlers.some(handler => handler.usesContext)
);
if (hasHoistedEventHandlerOrBinding) {
const initialProps: string[] = [];

@ -11,7 +11,9 @@ export default class Head extends Node {
constructor(compiler, parent, scope, info) {
super(compiler, parent, scope, info);
this.children = mapChildren(compiler, parent, scope, info.children);
this.children = mapChildren(compiler, parent, scope, info.children.filter(child => {
return (child.type !== 'Text' || /\S/.test(child.data));
}));
}
init(

@ -4,7 +4,7 @@ import * as path from "path";
import { rollup } from "rollup";
import { loadConfig, svelte } from "../helpers.js";
describe.only("js", () => {
describe("js", () => {
fs.readdirSync("test/js/samples").forEach(dir => {
if (dir[0] === ".") return;

@ -1,2 +1 @@
<title>a custom title</title>
<title>a custom title</title>
Loading…
Cancel
Save