revert remove contextual overflow (#4102)

pull/4125/head
Tan Li Hau 5 years ago committed by Conduitry
parent 0bb40196db
commit a8b306f0a1

@ -1,7 +1,7 @@
import Renderer from './Renderer'; import Renderer from './Renderer';
import Wrapper from './wrappers/shared/Wrapper'; import Wrapper from './wrappers/shared/Wrapper';
import { b, x } from 'code-red'; import { b, x } from 'code-red';
import { Node, Identifier } from 'estree'; import { Node, Identifier, ArrayPattern } from 'estree';
import { is_head } from './wrappers/shared/is_head'; import { is_head } from './wrappers/shared/is_head';
export interface BlockOptions { export interface BlockOptions {
@ -301,7 +301,12 @@ export default class Block {
} else { } else {
const ctx = this.maintain_context ? x`#new_ctx` : x`#ctx`; const ctx = this.maintain_context ? x`#new_ctx` : x`#ctx`;
properties.update = x`function #update(${ctx}, #dirty) { let dirty: Identifier | ArrayPattern = { type: 'Identifier', name: '#dirty' };
if (!this.renderer.context_overflow && !this.parent) {
dirty = { type: 'ArrayPattern', elements: [dirty] };
}
properties.update = x`function #update(${ctx}, ${dirty}) {
${this.maintain_context && b`#ctx = ${ctx};`} ${this.maintain_context && b`#ctx = ${ctx};`}
${this.chunks.update} ${this.chunks.update}
}`; }`;

@ -26,6 +26,7 @@ export default class Renderer {
context: ContextMember[] = []; context: ContextMember[] = [];
context_lookup: Map<string, ContextMember> = new Map(); context_lookup: Map<string, ContextMember> = new Map();
context_overflow: boolean;
blocks: Array<Block | Node | Node[]> = []; blocks: Array<Block | Node | Node[]> = [];
readonly: Set<string> = new Set(); readonly: Set<string> = new Set();
meta_bindings: Array<Node | Node[]> = []; // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag meta_bindings: Array<Node | Node[]> = []; // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag
@ -96,6 +97,8 @@ export default class Renderer {
this.fragment.render(this.block, null, x`#nodes` as Identifier); this.fragment.render(this.block, null, x`#nodes` as Identifier);
this.context_overflow = this.context.length > 31;
this.context.forEach(member => { this.context.forEach(member => {
const { variable } = member; const { variable } = member;
if (variable) { if (variable) {
@ -237,11 +240,15 @@ export default class Renderer {
return x`${dirty} & /*${names.join(', ')}*/ 0` as BinaryExpression; return x`${dirty} & /*${names.join(', ')}*/ 0` as BinaryExpression;
} }
return bitmask if (renderer.context_overflow) {
.map((b, i) => ({ b, i })) return bitmask
.filter(({ b }) => b) .map((b, i) => ({ b, i }))
.map(({ b, i }) => x`${dirty}[${i}] & /*${b.names.join(', ')}*/ ${b.n}`) .filter(({ b }) => b)
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`); .map(({ b, i }) => x`${dirty}[${i}] & /*${b.names.join(', ')}*/ ${b.n}`)
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`);
}
return x`${dirty} & /*${names.join(', ')}*/ ${bitmask[0].n}` as BinaryExpression;
} }
} as any; } as any;
} }

@ -429,7 +429,7 @@ export default function dom(
}` as ObjectExpression; }` as ObjectExpression;
let dirty; let dirty;
if (renderer.context.length > 31) { if (renderer.context_overflow) {
dirty = x`[]`; dirty = x`[]`;
for (let i = 0; i < renderer.context.length; i += 31) { for (let i = 0; i < renderer.context.length; i += 31) {
dirty.elements.push(x`-1`); dirty.elements.push(x`-1`);

@ -2,6 +2,7 @@ import Let from '../../../nodes/Let';
import { x, p } from 'code-red'; import { x, p } from 'code-red';
import Block from '../../Block'; import Block from '../../Block';
import TemplateScope from '../../../nodes/shared/TemplateScope'; import TemplateScope from '../../../nodes/shared/TemplateScope';
import { BinaryExpression } from 'estree';
export function get_slot_definition(block: Block, scope: TemplateScope, lets: Let[]) { export function get_slot_definition(block: Block, scope: TemplateScope, lets: Let[]) {
if (lets.length === 0) return { block, scope }; if (lets.length === 0) return { block, scope };
@ -35,30 +36,39 @@ export function get_slot_definition(block: Block, scope: TemplateScope, lets: Le
const changes = { const changes = {
type: 'ParenthesizedExpression', type: 'ParenthesizedExpression',
get expression() { get expression() {
const grouped = []; if (block.renderer.context_overflow) {
const grouped = [];
Array.from(names).forEach(name => { Array.from(names).forEach(name => {
const i = context_lookup.get(name).index.value as number; const i = context_lookup.get(name).index.value as number;
const g = Math.floor(i / 31); const g = Math.floor(i / 31);
if (!grouped[g]) grouped[g] = []; if (!grouped[g]) grouped[g] = [];
grouped[g].push({ name, n: i % 31 }); grouped[g].push({ name, n: i % 31 });
}); });
const elements = []; const elements = [];
for (let g = 0; g < grouped.length; g += 1) { for (let g = 0; g < grouped.length; g += 1) {
elements[g] = grouped[g] elements[g] = grouped[g]
? grouped[g] ? grouped[g]
.map(({ name, n }) => x`${name} ? ${1 << n} : 0`) .map(({ name, n }) => x`${name} ? ${1 << n} : 0`)
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`) .reduce((lhs, rhs) => x`${lhs} | ${rhs}`)
: x`0`; : x`0`;
}
return {
type: 'ArrayExpression',
elements
};
} }
return { return Array.from(names)
type: 'ArrayExpression', .map(name => {
elements const i = context_lookup.get(name).index.value as number;
}; return x`${name} ? ${1 << i} : 0`;
})
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`) as BinaryExpression;
} }
}; };

@ -80,16 +80,17 @@ export function get_slot_changes(definition, $$scope, dirty, fn) {
if (definition[2] && fn) { if (definition[2] && fn) {
const lets = definition[2](fn(dirty)); const lets = definition[2](fn(dirty));
if ($$scope.dirty) { if (typeof $$scope.dirty === 'object') {
const merged = []; const merged = [];
const len = Math.max($$scope.dirty.length, lets.length); const len = Math.max($$scope.dirty.length, lets.length);
for (let i = 0; i < len; i += 1) { for (let i = 0; i < len; i += 1) {
merged[i] = $$scope.dirty[i] | lets[i]; merged[i] = $$scope.dirty[i] | lets[i];
} }
return merged; return merged;
} }
return lets; return $$scope.dirty | lets;
} }
return $$scope.dirty; return $$scope.dirty;

@ -23,8 +23,8 @@ function create_fragment(ctx) {
insert(target, button, anchor); insert(target, button, anchor);
foo_action = foo.call(null, button, /*foo_function*/ ctx[1]) || ({}); foo_action = foo.call(null, button, /*foo_function*/ ctx[1]) || ({});
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (is_function(foo_action.update) && dirty[0] & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]); if (is_function(foo_action.update) && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -27,8 +27,8 @@ function create_fragment(ctx) {
insert(target, details, anchor); insert(target, details, anchor);
details.open = /*open*/ ctx[0]; details.open = /*open*/ ctx[0];
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*open*/ 1) { if (dirty & /*open*/ 1) {
details.open = /*open*/ ctx[0]; details.open = /*open*/ ctx[0];
} }
}, },

@ -37,10 +37,10 @@ function create_fragment(ctx) {
insert(target, input, anchor); insert(target, input, anchor);
set_input_value(input, /*foo*/ ctx[0]); set_input_value(input, /*foo*/ ctx[0]);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*foo*/ 1) set_data(t0, /*foo*/ ctx[0]); if (dirty & /*foo*/ 1) set_data(t0, /*foo*/ ctx[0]);
if (dirty[0] & /*foo*/ 1 && input.value !== /*foo*/ ctx[0]) { if (dirty & /*foo*/ 1 && input.value !== /*foo*/ ctx[0]) {
set_input_value(input, /*foo*/ ctx[0]); set_input_value(input, /*foo*/ ctx[0]);
} }
}, },

@ -34,8 +34,8 @@ function create_fragment(ctx) {
insert(target, p, anchor); insert(target, p, anchor);
append(p, t); append(p, t);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*foo*/ 1) set_data(t, /*foo*/ ctx[0]); if (dirty & /*foo*/ 1) set_data(t, /*foo*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -46,12 +46,12 @@ function create_fragment(ctx) {
set_input_value(input, /*z*/ ctx[0]); set_input_value(input, /*z*/ ctx[0]);
current = true; current = true;
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
const bar_changes = {}; const bar_changes = {};
if (dirty[0] & /*z*/ 1) bar_changes.x = /*z*/ ctx[0]; if (dirty & /*z*/ 1) bar_changes.x = /*z*/ ctx[0];
bar.$set(bar_changes); bar.$set(bar_changes);
if (dirty[0] & /*z*/ 1 && input.value !== /*z*/ ctx[0]) { if (dirty & /*z*/ 1 && input.value !== /*z*/ ctx[0]) {
set_input_value(input, /*z*/ ctx[0]); set_input_value(input, /*z*/ ctx[0]);
} }
}, },

@ -28,8 +28,8 @@ function create_fragment(ctx) {
insert(target, h1, anchor); insert(target, h1, anchor);
append(h1, t); append(h1, t);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*$foo*/ 1) set_data(t, /*$foo*/ ctx[0]); if (dirty & /*$foo*/ 1) set_data(t, /*$foo*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -39,8 +39,8 @@ function create_fragment(ctx) {
insert(target, t1, anchor); insert(target, t1, anchor);
insert(target, button, anchor); insert(target, button, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*$foo*/ 2) set_data(t0, /*$foo*/ ctx[1]); if (dirty & /*$foo*/ 2) set_data(t0, /*$foo*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -29,8 +29,8 @@ function create_fragment(ctx) {
insert(target, t, anchor); insert(target, t, anchor);
insert(target, div1, anchor); insert(target, div1, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*bar*/ 1) { if (dirty & /*bar*/ 1) {
attr(div1, "data-foo", /*bar*/ ctx[0]); attr(div1, "data-foo", /*bar*/ ctx[0]);
} }
}, },

@ -44,8 +44,8 @@ function create_fragment(ctx) {
append_dev(h1, t2); append_dev(h1, t2);
insert_dev(target, t3, anchor); insert_dev(target, t3, anchor);
}, },
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty[0] & /*name*/ 1) set_data_dev(t1, /*name*/ ctx[0]); if (dirty & /*name*/ 1) set_data_dev(t1, /*name*/ ctx[0]);
debugger; debugger;
}, },
i: noop, i: noop,

@ -54,9 +54,9 @@ function create_each_block(ctx) {
insert_dev(target, t1, anchor); insert_dev(target, t1, anchor);
}, },
p: function update(ctx, dirty) { p: function update(ctx, dirty) {
if (dirty[0] & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[4].name + "")) set_data_dev(t0, t0_value); if (dirty & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[4].name + "")) set_data_dev(t0, t0_value);
if (dirty[0] & /*foo, bar, baz, things*/ 15) { if (dirty & /*foo, bar, baz, things*/ 15) {
const foo = /*foo*/ ctx[1]; const foo = /*foo*/ ctx[1];
const bar = /*bar*/ ctx[2]; const bar = /*bar*/ ctx[2];
const baz = /*baz*/ ctx[3]; const baz = /*baz*/ ctx[3];
@ -119,8 +119,8 @@ function create_fragment(ctx) {
append_dev(p, t1); append_dev(p, t1);
append_dev(p, t2); append_dev(p, t2);
}, },
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty[0] & /*things*/ 1) { if (dirty & /*things*/ 1) {
each_value = /*things*/ ctx[0]; each_value = /*things*/ ctx[0];
let i; let i;
@ -143,7 +143,7 @@ function create_fragment(ctx) {
each_blocks.length = each_value.length; each_blocks.length = each_value.length;
} }
if (dirty[0] & /*foo*/ 2) set_data_dev(t2, /*foo*/ ctx[1]); if (dirty & /*foo*/ 2) set_data_dev(t2, /*foo*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -51,9 +51,9 @@ function create_each_block(ctx) {
insert_dev(target, t1, anchor); insert_dev(target, t1, anchor);
}, },
p: function update(ctx, dirty) { p: function update(ctx, dirty) {
if (dirty[0] & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[2].name + "")) set_data_dev(t0, t0_value); if (dirty & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[2].name + "")) set_data_dev(t0, t0_value);
if (dirty[0] & /*foo*/ 2) { if (dirty & /*foo*/ 2) {
const foo = /*foo*/ ctx[1]; const foo = /*foo*/ ctx[1];
console.log({ foo }); console.log({ foo });
debugger; debugger;
@ -113,8 +113,8 @@ function create_fragment(ctx) {
append_dev(p, t1); append_dev(p, t1);
append_dev(p, t2); append_dev(p, t2);
}, },
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty[0] & /*things*/ 1) { if (dirty & /*things*/ 1) {
each_value = /*things*/ ctx[0]; each_value = /*things*/ ctx[0];
let i; let i;
@ -137,7 +137,7 @@ function create_fragment(ctx) {
each_blocks.length = each_value.length; each_blocks.length = each_value.length;
} }
if (dirty[0] & /*foo*/ 2) set_data_dev(t2, /*foo*/ ctx[1]); if (dirty & /*foo*/ 2) set_data_dev(t2, /*foo*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -23,8 +23,8 @@ function create_fragment(ctx) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
}, },
m: noop, m: noop,
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty[0] & /*obj, kobzol*/ 3) { if (dirty & /*obj, kobzol*/ 3) {
const obj = /*obj*/ ctx[0]; const obj = /*obj*/ ctx[0];
const kobzol = /*kobzol*/ ctx[1]; const kobzol = /*kobzol*/ ctx[1];
console.log({ obj, kobzol }); console.log({ obj, kobzol });

@ -88,7 +88,7 @@ function create_fragment(ctx) {
insert_dev(target, each_1_anchor, anchor); insert_dev(target, each_1_anchor, anchor);
}, },
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty & /*things*/ 0) { if (dirty & /*things*/ 0) {
each_value = things; each_value = things;
let i; let i;

@ -36,7 +36,7 @@ function create_each_block(ctx) {
append(span, t); append(span, t);
}, },
p(ctx, dirty) { p(ctx, dirty) {
if (dirty[0] & /*createElement*/ 1 && t_value !== (t_value = /*node*/ ctx[1] + "")) set_data(t, t_value); if (dirty & /*createElement*/ 1 && t_value !== (t_value = /*node*/ ctx[1] + "")) set_data(t, t_value);
}, },
d(detaching) { d(detaching) {
if (detaching) detach(span); if (detaching) detach(span);
@ -68,8 +68,8 @@ function create_fragment(ctx) {
insert(target, each_1_anchor, anchor); insert(target, each_1_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*createElement*/ 1) { if (dirty & /*createElement*/ 1) {
each_value = /*createElement*/ ctx[0]; each_value = /*createElement*/ ctx[0];
let i; let i;

@ -41,9 +41,9 @@ function create_fragment(ctx) {
append_dev(p, t1); append_dev(p, t1);
append_dev(p, t2); append_dev(p, t2);
}, },
p: function update(ctx, dirty) { p: function update(ctx, [dirty]) {
if (dirty[0] & /*foo*/ 1 && t0_value !== (t0_value = Math.max(0, /*foo*/ ctx[0]) + "")) set_data_dev(t0, t0_value); if (dirty & /*foo*/ 1 && t0_value !== (t0_value = Math.max(0, /*foo*/ ctx[0]) + "")) set_data_dev(t0, t0_value);
if (dirty[0] & /*bar*/ 2) set_data_dev(t2, /*bar*/ ctx[1]); if (dirty & /*bar*/ 2) set_data_dev(t2, /*bar*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,
@ -86,7 +86,7 @@ function instance($$self, $$props, $$invalidate) {
}; };
$$self.$$.update = () => { $$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*foo*/ 1) { if ($$self.$$.dirty & /*foo*/ 1) {
$: $$invalidate(1, bar = foo * 2); $: $$invalidate(1, bar = foo * 2);
} }
}; };

@ -36,7 +36,7 @@ function create_each_block(ctx) {
append(span, t); append(span, t);
}, },
p(ctx, dirty) { p(ctx, dirty) {
if (dirty[0] & /*a, b, c, d, e*/ 31 && t_value !== (t_value = /*num*/ ctx[5] + "")) set_data(t, t_value); if (dirty & /*a, b, c, d, e*/ 31 && t_value !== (t_value = /*num*/ ctx[5] + "")) set_data(t, t_value);
}, },
d(detaching) { d(detaching) {
if (detaching) detach(span); if (detaching) detach(span);
@ -68,8 +68,8 @@ function create_fragment(ctx) {
insert(target, each_1_anchor, anchor); insert(target, each_1_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*a, b, c, d, e*/ 31) { if (dirty & /*a, b, c, d, e*/ 31) {
each_value = [/*a*/ ctx[0], /*b*/ ctx[1], /*c*/ ctx[2], /*d*/ ctx[3], /*e*/ ctx[4]]; each_value = [/*a*/ ctx[0], /*b*/ ctx[1], /*c*/ ctx[2], /*d*/ ctx[3], /*e*/ ctx[4]];
let i; let i;

@ -70,9 +70,9 @@ function create_each_block(ctx) {
html_tag.m(div); html_tag.m(div);
}, },
p(ctx, dirty) { p(ctx, dirty) {
if (dirty[0] & /*comments*/ 1 && t2_value !== (t2_value = /*comment*/ ctx[4].author + "")) set_data(t2, t2_value); if (dirty & /*comments*/ 1 && t2_value !== (t2_value = /*comment*/ ctx[4].author + "")) set_data(t2, t2_value);
if (dirty[0] & /*elapsed, comments, time*/ 7 && t4_value !== (t4_value = /*elapsed*/ ctx[1](/*comment*/ ctx[4].time, /*time*/ ctx[2]) + "")) set_data(t4, t4_value); if (dirty & /*elapsed, comments, time*/ 7 && t4_value !== (t4_value = /*elapsed*/ ctx[1](/*comment*/ ctx[4].time, /*time*/ ctx[2]) + "")) set_data(t4, t4_value);
if (dirty[0] & /*comments*/ 1 && raw_value !== (raw_value = /*comment*/ ctx[4].html + "")) html_tag.p(raw_value); if (dirty & /*comments*/ 1 && raw_value !== (raw_value = /*comment*/ ctx[4].html + "")) html_tag.p(raw_value);
}, },
d(detaching) { d(detaching) {
if (detaching) detach(div); if (detaching) detach(div);
@ -110,8 +110,8 @@ function create_fragment(ctx) {
insert(target, p, anchor); insert(target, p, anchor);
append(p, t1); append(p, t1);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*comments, elapsed, time*/ 7) { if (dirty & /*comments, elapsed, time*/ 7) {
each_value = /*comments*/ ctx[0]; each_value = /*comments*/ ctx[0];
let i; let i;
@ -134,7 +134,7 @@ function create_fragment(ctx) {
each_blocks.length = each_value.length; each_blocks.length = each_value.length;
} }
if (dirty[0] & /*foo*/ 8) set_data(t1, /*foo*/ ctx[3]); if (dirty & /*foo*/ 8) set_data(t1, /*foo*/ ctx[3]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -44,7 +44,7 @@ function create_each_block(key_1, ctx) {
append(div, t); append(div, t);
}, },
p(ctx, dirty) { p(ctx, dirty) {
if (dirty[0] & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value); if (dirty & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value);
}, },
r() { r() {
rect = div.getBoundingClientRect(); rect = div.getBoundingClientRect();
@ -91,7 +91,7 @@ function create_fragment(ctx) {
insert(target, each_1_anchor, anchor); insert(target, each_1_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
const each_value = /*things*/ ctx[0]; const each_value = /*things*/ ctx[0];
for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].r(); for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].r();
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, fix_and_destroy_block, create_each_block, each_1_anchor, get_each_context); each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, fix_and_destroy_block, create_each_block, each_1_anchor, get_each_context);

@ -40,7 +40,7 @@ function create_each_block(key_1, ctx) {
append(div, t); append(div, t);
}, },
p(ctx, dirty) { p(ctx, dirty) {
if (dirty[0] & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value); if (dirty & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value);
}, },
d(detaching) { d(detaching) {
if (detaching) detach(div); if (detaching) detach(div);
@ -76,7 +76,7 @@ function create_fragment(ctx) {
insert(target, each_1_anchor, anchor); insert(target, each_1_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
const each_value = /*things*/ ctx[0]; const each_value = /*things*/ ctx[0];
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, destroy_block, create_each_block, each_1_anchor, get_each_context); each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, destroy_block, create_each_block, each_1_anchor, get_each_context);
}, },

@ -61,9 +61,9 @@ function create_fragment(ctx) {
insert(target, t5, anchor); insert(target, t5, anchor);
insert(target, button2, anchor); insert(target, button2, anchor);
}, },
p(new_ctx, dirty) { p(new_ctx, [dirty]) {
ctx = new_ctx; ctx = new_ctx;
if (dirty[0] & /*number*/ 2) set_data(t4, /*number*/ ctx[1]); if (dirty & /*number*/ 2) set_data(t4, /*number*/ ctx[1]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -65,7 +65,7 @@ function create_fragment(ctx) {
if_block.m(target, anchor); if_block.m(target, anchor);
insert(target, if_block_anchor, anchor); insert(target, if_block_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (current_block_type !== (current_block_type = select_block_type(ctx, dirty))) { if (current_block_type !== (current_block_type = select_block_type(ctx, dirty))) {
if_block.d(1); if_block.d(1);
if_block = current_block_type(ctx); if_block = current_block_type(ctx);

@ -40,7 +40,7 @@ function create_fragment(ctx) {
if (if_block) if_block.m(target, anchor); if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor); insert(target, if_block_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (/*foo*/ ctx[0]) { if (/*foo*/ ctx[0]) {
if (!if_block) { if (!if_block) {
if_block = create_if_block(ctx); if_block = create_if_block(ctx);

@ -22,12 +22,12 @@ function create_fragment(ctx) {
m(target, anchor) { m(target, anchor) {
insert(target, div, anchor); insert(target, div, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*color*/ 1) { if (dirty & /*color*/ 1) {
set_style(div, "color", /*color*/ ctx[0]); set_style(div, "color", /*color*/ ctx[0]);
} }
if (dirty[0] & /*x, y*/ 6) { if (dirty & /*x, y*/ 6) {
set_style(div, "transform", "translate(" + /*x*/ ctx[1] + "px," + /*y*/ ctx[2] + "px)"); set_style(div, "transform", "translate(" + /*x*/ ctx[1] + "px," + /*y*/ ctx[2] + "px)");
} }
}, },

@ -21,8 +21,8 @@ function create_fragment(ctx) {
m(target, anchor) { m(target, anchor) {
insert(target, div, anchor); insert(target, div, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*data*/ 1) { if (dirty & /*data*/ 1) {
set_style(div, "background", "url(data:image/png;base64," + /*data*/ ctx[0] + ")"); set_style(div, "background", "url(data:image/png;base64," + /*data*/ ctx[0] + ")");
} }
}, },

@ -21,8 +21,8 @@ function create_fragment(ctx) {
m(target, anchor) { m(target, anchor) {
insert(target, div, anchor); insert(target, div, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*color*/ 1) { if (dirty & /*color*/ 1) {
set_style(div, "color", /*color*/ ctx[0]); set_style(div, "color", /*color*/ ctx[0]);
} }
}, },

@ -30,12 +30,12 @@ function create_fragment(ctx) {
insert(target, t, anchor); insert(target, t, anchor);
insert(target, div1, anchor); insert(target, div1, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*style*/ 1) { if (dirty & /*style*/ 1) {
attr(div0, "style", /*style*/ ctx[0]); attr(div0, "style", /*style*/ ctx[0]);
} }
if (dirty[0] & /*key, value*/ 6 && div1_style_value !== (div1_style_value = "" + (/*key*/ ctx[1] + ": " + /*value*/ ctx[2]))) { if (dirty & /*key, value*/ 6 && div1_style_value !== (div1_style_value = "" + (/*key*/ ctx[1] + ": " + /*value*/ ctx[2]))) {
attr(div1, "style", div1_style_value); attr(div1, "style", div1_style_value);
} }
}, },

@ -44,8 +44,8 @@ function create_fragment(ctx) {
append(form, t0); append(form, t0);
append(form, button); append(form, button);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*test*/ 1 && input.value !== /*test*/ ctx[0]) { if (dirty & /*test*/ 1 && input.value !== /*test*/ ctx[0]) {
set_input_value(input, /*test*/ ctx[0]); set_input_value(input, /*test*/ ctx[0]);
} }
}, },

@ -32,8 +32,8 @@ function create_fragment(ctx) {
insert(target, input, anchor); insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]); set_input_value(input, /*value*/ ctx[0]);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*value*/ 1) { if (dirty & /*value*/ 1) {
set_input_value(input, /*value*/ ctx[0]); set_input_value(input, /*value*/ ctx[0]);
} }
}, },

@ -25,8 +25,8 @@ function create_fragment(ctx) {
insert(target, input, anchor); insert(target, input, anchor);
input.checked = /*foo*/ ctx[0]; input.checked = /*foo*/ ctx[0];
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*foo*/ 1) { if (dirty & /*foo*/ 1) {
input.checked = /*foo*/ ctx[0]; input.checked = /*foo*/ ctx[0];
} }
}, },

@ -39,8 +39,8 @@ function create_fragment(ctx) {
append(p, t2); append(p, t2);
append(p, t3); append(p, t3);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*x*/ 1) set_data(t3, /*x*/ ctx[0]); if (dirty & /*x*/ 1) set_data(t3, /*x*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -28,8 +28,8 @@ function create_fragment(ctx) {
append(p, t0); append(p, t0);
append(p, t1); append(p, t1);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*x*/ 1) set_data(t1, /*x*/ ctx[0]); if (dirty & /*x*/ 1) set_data(t1, /*x*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,
@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) {
); );
$$self.$$.update = () => { $$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*x, y*/ 3) { if ($$self.$$.dirty & /*x, y*/ 3) {
$: $$invalidate(0, x += y); $: $$invalidate(0, x += y);
} }
}; };

@ -40,8 +40,8 @@ function create_fragment(ctx) {
append(p, t2); append(p, t2);
append(p, t3); append(p, t3);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value); if (dirty & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -39,8 +39,8 @@ function create_fragment(ctx) {
append(p, t2); append(p, t2);
append(p, t3); append(p, t3);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*x*/ 1) set_data(t3, /*x*/ ctx[0]); if (dirty & /*x*/ 1) set_data(t3, /*x*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -40,8 +40,8 @@ function create_fragment(ctx) {
append(p, t2); append(p, t2);
append(p, t3); append(p, t3);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value); if (dirty & /*things*/ 1 && t3_value !== (t3_value = /*things*/ ctx[0].length + "")) set_data(t3, t3_value);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -67,20 +67,20 @@ function create_fragment(ctx) {
audio.playbackRate = /*playbackRate*/ ctx[7]; audio.playbackRate = /*playbackRate*/ ctx[7];
} }
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (!audio_updating && dirty[0] & /*currentTime*/ 8 && !isNaN(/*currentTime*/ ctx[3])) { if (!audio_updating && dirty & /*currentTime*/ 8 && !isNaN(/*currentTime*/ ctx[3])) {
audio.currentTime = /*currentTime*/ ctx[3]; audio.currentTime = /*currentTime*/ ctx[3];
} }
if (dirty[0] & /*paused*/ 32 && audio_is_paused !== (audio_is_paused = /*paused*/ ctx[5])) { if (dirty & /*paused*/ 32 && audio_is_paused !== (audio_is_paused = /*paused*/ ctx[5])) {
audio[audio_is_paused ? "pause" : "play"](); audio[audio_is_paused ? "pause" : "play"]();
} }
if (dirty[0] & /*volume*/ 64 && !isNaN(/*volume*/ ctx[6])) { if (dirty & /*volume*/ 64 && !isNaN(/*volume*/ ctx[6])) {
audio.volume = /*volume*/ ctx[6]; audio.volume = /*volume*/ ctx[6];
} }
if (dirty[0] & /*playbackRate*/ 128 && !isNaN(/*playbackRate*/ ctx[7])) { if (dirty & /*playbackRate*/ 128 && !isNaN(/*playbackRate*/ ctx[7])) {
audio.playbackRate = /*playbackRate*/ ctx[7]; audio.playbackRate = /*playbackRate*/ ctx[7];
} }

@ -11,11 +11,11 @@ function instance($$self, $$props, $$invalidate) {
}; };
$$self.$$.update = () => { $$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*x*/ 1) { if ($$self.$$.dirty & /*x*/ 1) {
$: $$invalidate(2, b = x); $: $$invalidate(2, b = x);
} }
if ($$self.$$.dirty[0] & /*b*/ 4) { if ($$self.$$.dirty & /*b*/ 4) {
$: a = b; $: a = b;
} }
}; };

@ -11,7 +11,7 @@ function instance($$self, $$props, $$invalidate) {
}; };
$$self.$$.update = () => { $$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*a, b*/ 3) { if ($$self.$$.dirty & /*a, b*/ 3) {
$: console.log("max", Math.max(a, b)); $: console.log("max", Math.max(a, b));
} }
}; };

@ -43,8 +43,8 @@ function create_fragment(ctx) {
} }
} }
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*current*/ 1 && select_value_value !== (select_value_value = /*current*/ ctx[0])) { if (dirty & /*current*/ 1 && select_value_value !== (select_value_value = /*current*/ ctx[0])) {
for (var i = 0; i < select.options.length; i += 1) { for (var i = 0; i < select.options.length; i += 1) {
var option = select.options[i]; var option = select.options[i];

@ -44,12 +44,12 @@ function create_fragment(ctx) {
insert(target, t, anchor); insert(target, t, anchor);
insert(target, img1, anchor); insert(target, img1, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*url*/ 1 && img0.src !== (img0_src_value = /*url*/ ctx[0])) { if (dirty & /*url*/ 1 && img0.src !== (img0_src_value = /*url*/ ctx[0])) {
attr(img0, "src", img0_src_value); attr(img0, "src", img0_src_value);
} }
if (dirty[0] & /*slug*/ 2 && img1.src !== (img1_src_value = "" + (/*slug*/ ctx[1] + ".jpg"))) { if (dirty & /*slug*/ 2 && img1.src !== (img1_src_value = "" + (/*slug*/ ctx[1] + ".jpg"))) {
attr(img1, "src", img1_src_value); attr(img1, "src", img1_src_value);
} }
}, },

@ -8,8 +8,8 @@ function create_fragment(ctx) {
return { return {
c: noop, c: noop,
m: noop, m: noop,
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*custom*/ 1 && title_value !== (title_value = "a " + /*custom*/ ctx[0] + " title")) { if (dirty & /*custom*/ 1 && title_value !== (title_value = "a " + /*custom*/ ctx[0] + " title")) {
document.title = title_value; document.title = title_value;
} }
}, },

@ -91,7 +91,7 @@ function create_fragment(ctx) {
if (if_block) if_block.m(target, anchor); if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor); insert(target, if_block_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (/*x*/ ctx[0]) { if (/*x*/ ctx[0]) {
if (if_block) { if (if_block) {
if_block.p(ctx, dirty); if_block.p(ctx, dirty);

@ -61,7 +61,7 @@ function create_fragment(ctx) {
insert(target, if_block_anchor, anchor); insert(target, if_block_anchor, anchor);
current = true; current = true;
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (/*num*/ ctx[0] < 5) { if (/*num*/ ctx[0] < 5) {
if (!if_block) { if (!if_block) {
if_block = create_if_block(ctx); if_block = create_if_block(ctx);

@ -56,8 +56,8 @@ function create_fragment(ctx) {
append(p3, t8); append(p3, t8);
append(p3, t9); append(p3, t9);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*world3*/ 1) set_data(t9, /*world3*/ ctx[0]); if (dirty & /*world3*/ 1) set_data(t9, /*world3*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -27,8 +27,8 @@ function create_fragment(ctx) {
insert(target, p, anchor); insert(target, p, anchor);
append(p, t); append(p, t);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*y*/ 1) set_data(t, /*y*/ ctx[0]); if (dirty & /*y*/ 1) set_data(t, /*y*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,
@ -58,7 +58,7 @@ function instance($$self, $$props, $$invalidate) {
let y; let y;
$$self.$$.update = () => { $$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*b*/ 2) { if ($$self.$$.dirty & /*b*/ 2) {
$: $$invalidate(0, y = b * 2); $: $$invalidate(0, y = b * 2);
} }
}; };

@ -155,7 +155,7 @@ function create_fragment(ctx) {
if (if_block4) if_block4.m(target, anchor); if (if_block4) if_block4.m(target, anchor);
insert(target, if_block4_anchor, anchor); insert(target, if_block4_anchor, anchor);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (/*a*/ ctx[0]) { if (/*a*/ ctx[0]) {
if (!if_block0) { if (!if_block0) {
if_block0 = create_if_block_4(ctx); if_block0 = create_if_block_4(ctx);

@ -47,8 +47,8 @@ function create_fragment(ctx) {
insert(target, video, anchor); insert(target, video, anchor);
video_resize_listener = add_resize_listener(video, /*video_elementresize_handler*/ ctx[4].bind(video)); video_resize_listener = add_resize_listener(video, /*video_elementresize_handler*/ ctx[4].bind(video));
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (!video_updating && dirty[0] & /*currentTime*/ 1 && !isNaN(/*currentTime*/ ctx[0])) { if (!video_updating && dirty & /*currentTime*/ 1 && !isNaN(/*currentTime*/ ctx[0])) {
video.currentTime = /*currentTime*/ ctx[0]; video.currentTime = /*currentTime*/ ctx[0];
} }

@ -46,15 +46,15 @@ function create_fragment(ctx) {
append(p, t0); append(p, t0);
append(p, t1); append(p, t1);
}, },
p(ctx, dirty) { p(ctx, [dirty]) {
if (dirty[0] & /*y*/ 1 && !scrolling) { if (dirty & /*y*/ 1 && !scrolling) {
scrolling = true; scrolling = true;
clearTimeout(scrolling_timeout); clearTimeout(scrolling_timeout);
scrollTo(window.pageXOffset, /*y*/ ctx[0]); scrollTo(window.pageXOffset, /*y*/ ctx[0]);
scrolling_timeout = setTimeout(clear_scrolling, 100); scrolling_timeout = setTimeout(clear_scrolling, 100);
} }
if (dirty[0] & /*y*/ 1) set_data(t1, /*y*/ ctx[0]); if (dirty & /*y*/ 1) set_data(t1, /*y*/ ctx[0]);
}, },
i: noop, i: noop,
o: noop, o: noop,

@ -0,0 +1,73 @@
<script>
export let d1 = 'd1';
export let d2 = 'd2';
export let d3 = 'd3';
export let d4 = 'd4';
export let d5 = 'd5';
export let d6 = 'd6';
export let d7 = 'd7';
export let d8 = 'd8';
export let d9 = 'd9';
export let d10 = 'd10';
export let d11 = 'd11';
export let d12 = 'd12';
export let d13 = 'd13';
export let d14 = 'd14';
export let d15 = 'd15';
export let d16 = 'd16';
export let d17 = 'd17';
export let d18 = 'd18';
export let d19 = 'd19';
export let d20 = 'd20';
export let d21 = 'd21';
export let d22 = 'd22';
export let d23 = 'd23';
export let d24 = 'd24';
export let d25 = 'd25';
export let d26 = 'd26';
export let d27 = 'd27';
export let d28 = 'd28';
export let d29 = 'd29';
export let d30 = 'd30';
export let d31 = 'd31';
export let d32 = 'd32';
export let d33 = 'd33';
$: dummy = d32 + ':' + d33;
</script>
<p>{d1}</p>
<p>{d2}</p>
<p>{d3}</p>
<p>{d4}</p>
<p>{d5}</p>
<p>{d6}</p>
<p>{d7}</p>
<p>{d8}</p>
<p>{d9}</p>
<p>{d10}</p>
<p>{d11}</p>
<p>{d12}</p>
<p>{d13}</p>
<p>{d14}</p>
<p>{d15}</p>
<p>{d16}</p>
<p>{d17}</p>
<p>{d18}</p>
<p>{d19}</p>
<p>{d20}</p>
<p>{d21}</p>
<p>{d22}</p>
<p>{d23}</p>
<p>{d24}</p>
<p>{d25}</p>
<p>{d26}</p>
<p>{d27}</p>
<p>{d28}</p>
<p>{d29}</p>
<p>{d30}</p>
<p>{d31}</p>
<p>{d32}</p>
<p>{d33}</p>
<slot dummy={dummy}></slot>

@ -0,0 +1,96 @@
export default {
html: `
<p>d1</p>
<p>d2</p>
<p>d3</p>
<p>d4</p>
<p>d5</p>
<p>d6</p>
<p>d7</p>
<p>d8</p>
<p>d9</p>
<p>d10</p>
<p>d11</p>
<p>d12</p>
<p>d13</p>
<p>d14</p>
<p>d15</p>
<p>d16</p>
<p>d17</p>
<p>d18</p>
<p>d19</p>
<p>d20</p>
<p>d21</p>
<p>d22</p>
<p>d23</p>
<p>d24</p>
<p>d25</p>
<p>d26</p>
<p>d27</p>
<p>d28</p>
<p>d29</p>
<p>d30</p>
<p>d31</p>
<p>2</p>
<p>1</p>
<p>0:1</p>
<p>2:1</p>
<p>0</p>
<p>1</p>
<p>2</p>
`,
test({ assert, component, target }) {
component.reads = {};
component._0 = 'a';
component._1 = 'b';
component._2 = 'c';
assert.htmlEqual(target.innerHTML, `
<p>d1</p>
<p>d2</p>
<p>d3</p>
<p>d4</p>
<p>d5</p>
<p>d6</p>
<p>d7</p>
<p>d8</p>
<p>d9</p>
<p>d10</p>
<p>d11</p>
<p>d12</p>
<p>d13</p>
<p>d14</p>
<p>d15</p>
<p>d16</p>
<p>d17</p>
<p>d18</p>
<p>d19</p>
<p>d20</p>
<p>d21</p>
<p>d22</p>
<p>d23</p>
<p>d24</p>
<p>d25</p>
<p>d26</p>
<p>d27</p>
<p>d28</p>
<p>d29</p>
<p>d30</p>
<p>d31</p>
<p>c</p>
<p>b</p>
<p>a:b</p>
<p>c:b</p>
<p>a</p>
<p>b</p>
<p>c</p>
`);
assert.deepEqual(component.reads, {
_0: 2,
_1: 2,
});
}
};

@ -0,0 +1,30 @@
<script>
import Echo from './Echo.svelte';
export let reads = {};
export let _0 = '0';
export let _1 = '1';
export let _2 = '2';
$: bar = read(_0, '_0') + ':' + read(_1, '_1');
const read = (value, label) => {
if (!reads[label]) reads[label] = 0;
reads[label] += 1;
return value;
};
</script>
<Echo
let:dummy
d33={_1}
d32={_2}
>
<p>{bar}</p>
<p>{dummy}</p>
<p>{_0}</p>
<p>{_1}</p>
<p>{_2}</p>
</Echo>

@ -0,0 +1,8 @@
export default {
html: `
<p>OK</p>
<p>OK</p>
<pre>one</pre>
<pre>two</pre>
`
};

@ -0,0 +1,13 @@
<script>
let a = () => true;
export let data = [{ foo: [{ foo: [{bar: "one"}, {bar: "two"}] }] }];
</script>
{#each data as datum}
{#if datum.foo && a()}
<p>OK</p>
<svelte:self data={datum.foo}/>
{:else}
<pre>{datum.bar}</pre>
{/if}
{/each}

@ -0,0 +1,12 @@
<script>
import {writable} from 'svelte/store';
import Widget from './Widget.svelte';
let a = (writable({}));
let b = () => true;
</script>
<!-- if (reactive && non-reactive) -->
{#if $a || b() }
<Widget></Widget>
{:else}
<pre>fail</pre>
{/if}
Loading…
Cancel
Save