recalculate each block values lazily - fixes #1286

pull/1378/head
Rich Harris 7 years ago
parent ed605bfa79
commit f0bf1ef8d5

@ -443,9 +443,9 @@ export default class EachBlock extends Node {
`;
block.builders.update.addBlock(deindent`
var ${each_block_value} = ${snippet};
if (${condition}) {
${each_block_value} = ${snippet};
for (var #i = ${start}; #i < ${each_block_value}.${length}; #i += 1) {
var ${this.each_context} = @assign(@assign({}, ctx), {
${this.contextProps.join(',\n')}

@ -186,9 +186,9 @@ function create_main_fragment(component, ctx) {
},
p: function update(changed, ctx) {
var each_value = ctx.createElement;
if (changed.createElement) {
each_value = ctx.createElement;
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign(assign({}, ctx), {
each_value: each_value,

@ -34,9 +34,9 @@ function create_main_fragment(component, ctx) {
},
p: function update(changed, ctx) {
var each_value = ctx.createElement;
if (changed.createElement) {
each_value = ctx.createElement;
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign(assign({}, ctx), {
each_value: each_value,

@ -192,9 +192,9 @@ function create_main_fragment(component, ctx) {
},
p: function update(changed, ctx) {
var each_value = ctx.comments;
if (changed.comments || changed.elapsed || changed.time) {
each_value = ctx.comments;
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign(assign({}, ctx), {
each_value: each_value,

@ -38,9 +38,9 @@ function create_main_fragment(component, ctx) {
},
p: function update(changed, ctx) {
var each_value = ctx.comments;
if (changed.comments || changed.elapsed || changed.time) {
each_value = ctx.comments;
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign(assign({}, ctx), {
each_value: each_value,

Loading…
Cancel
Save