Merge pull request #1378 from sveltejs/gh-1286

recalculate each block values lazily
pull/1381/head
Rich Harris 7 years ago committed by GitHub
commit 7246997dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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