Skip to content

Commit

Permalink
fix arrow function precedence (sveltejs#4385)
Browse files Browse the repository at this point in the history
* update code-red

* fix code-red usage

* update changelog
  • Loading branch information
Conduitry authored and taylorzane committed Dec 17, 2020
1 parent 48906d1 commit 1a9f072
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Fix binding to module-level variables ([#4086](https://github.com/sveltejs/svelte/issues/4086))
* Disallow attribute/prop names from matching two-way-bound names or `{shorthand}` attribute/prop names ([#4325](https://github.com/sveltejs/svelte/issues/4325))
* Fix code generation error with precedence of arrow functions ([#4384](https://github.com/sveltejs/svelte/issues/4384))

## 3.18.1

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"acorn": "^7.1.0",
"agadoo": "^1.1.0",
"c8": "^5.0.1",
"code-red": "0.0.32",
"code-red": "0.1.1",
"codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default class Renderer {

return filtered
.map(n => x`$$invalidate(${this.context_lookup.get(n).index}, ${n})`)
.reduce((lhs, rhs) => x`${lhs}, ${rhs}}`);
.reduce((lhs, rhs) => x`${lhs}, ${rhs}`);
}

dirty(names, is_reactive_declaration = false): Expression {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ export default function dom(
${set && b`$$self.$set = ${set};`}
${capture_state && x`$$self.$capture_state = ${capture_state};`}
${capture_state && b`$$self.$capture_state = ${capture_state};`}
${inject_state && x`$$self.$inject_state = ${inject_state};`}
${inject_state && b`$$self.$inject_state = ${inject_state};`}
${injected.map(name => b`let ${name};`)}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/invalidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function invalidate(renderer: Renderer, scope: Scope, node: Node, names:

if (head.subscribable && head.reassigned) {
const subscribe = `$$subscribe_${head.name}`;
invalidate = x`${subscribe}(${invalidate})}`;
invalidate = x`${subscribe}(${invalidate})`;
}

return invalidate;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/render_dom/wrappers/AwaitBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class AwaitBlockWrapper extends Wrapper {
} else {
const #child_ctx = #ctx.slice();
${this.node.value && x`#child_ctx[${value_index}] = ${info}.resolved;`}
${this.node.value && b`#child_ctx[${value_index}] = ${info}.resolved;`}
${info}.block.p(#child_ctx, #dirty);
}
`);
Expand All @@ -219,7 +219,7 @@ export default class AwaitBlockWrapper extends Wrapper {
block.chunks.update.push(b`
{
const #child_ctx = #ctx.slice();
${this.node.value && x`#child_ctx[${value_index}] = ${info}.resolved;`}
${this.node.value && b`#child_ctx[${value_index}] = ${info}.resolved;`}
${info}.block.p(#child_ctx, #dirty);
}
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class BindingWrapper {
const type = parent.node.get_static_attribute_value('type');

if (type === null || type === "" || type === "text" || type === "email" || type === "password") {
update_conditions.push(x`(${parent.var}.${this.node.name} !== ${this.snippet})`);
update_conditions.push(x`${parent.var}.${this.node.name} !== ${this.snippet}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/render_dom/wrappers/Element/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default class ElementWrapper extends Wrapper {

const is = this.attributes.find(attr => attr.node.name === 'is');
if (is) {
return x`@element_is("${name}", ${is.render_chunks(block).reduce((lhs, rhs) => x`${lhs} + ${rhs}`)});`;
return x`@element_is("${name}", ${is.render_chunks(block).reduce((lhs, rhs) => x`${lhs} + ${rhs}`)})`;
}

return x`@element("${name}")`;
Expand Down Expand Up @@ -632,7 +632,7 @@ export default class ElementWrapper extends Wrapper {

add_this_binding(block: Block, this_binding: Binding) {
const { renderer } = this;

renderer.component.has_reactive_assignments = true;

const binding_callback = bind_this(renderer.component, block, this_binding.node, this.var);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/wrappers/MustacheTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class MustacheTagWrapper extends Tag {
render(block: Block, parent_node: Identifier, parent_nodes: Identifier) {
const { init } = this.rename_this_method(
block,
value => x`@set_data(${this.var}, ${value});`
value => x`@set_data(${this.var}, ${value})`
);

block.add_element(
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class RawMustacheTagWrapper extends Tag {

const { init } = this.rename_this_method(
block,
content => x`${html_tag}.p(${content});`
content => x`${html_tag}.p(${content})`
);

const update_anchor = in_head ? 'null' : needs_anchor ? html_anchor : this.next ? this.next.var : 'null';
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/render_ssr/handlers/AwaitBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default function(node: AwaitBlock, renderer: Renderer, options: RenderOpt
const then = renderer.pop();

renderer.add_expression(x`
(function(__value) {
function(__value) {
if (@is_promise(__value)) return ${pending};
return (function(${node.value}) { return ${then}; }(__value));
}(${node.expression.node}))
}(${node.expression.node})
`);
}
2 changes: 1 addition & 1 deletion src/compiler/compile/render_ssr/handlers/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
}
});

renderer.add_expression(x`@spread([${args}], ${class_expression});`);
renderer.add_expression(x`@spread([${args}], ${class_expression})`);
} else {
let add_class_attribute = !!class_expression;
node.attributes.forEach(attribute => {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render_ssr/handlers/Head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default function(node: Head, renderer: Renderer, options: RenderOptions)
renderer.render(node.children, head_options);
const result = renderer.pop();

renderer.add_expression(x`($$result.head += ${result}, "")`);
renderer.add_expression(x`$$result.head += ${result}, ""`);
}
2 changes: 1 addition & 1 deletion src/compiler/compile/render_ssr/handlers/Title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default function(node: Title, renderer: Renderer, options: RenderOptions)
renderer.add_string(`</title>`);
const result = renderer.pop();

renderer.add_expression(x`($$result.title = ${result}, "")`);
renderer.add_expression(x`$$result.title = ${result}, ""`);
}

0 comments on commit 1a9f072

Please sign in to comment.