You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/js/samples/each-block-changed-check/expected.js

177 lines
3.8 KiB

/* generated by Svelte vX.Y.Z */
6 years ago
import {
SvelteComponent,
6 years ago
append,
destroy_each,
detach,
detach_after,
element,
init,
insert,
noop,
safe_not_equal,
set_data,
space,
6 years ago
text
} from "svelte/internal";
function get_each_context(ctx, list, i) {
const child_ctx = Object.create(ctx);
child_ctx.comment = list[i];
child_ctx.i = i;
return child_ctx;
}
// (8:0) {#each comments as comment, i}
function create_each_block(ctx) {
6 years ago
var div, strong, t0, t1, span, t2_value = ctx.comment.author, t2, t3, t4_value = ctx.elapsed(ctx.comment.time, ctx.time), t4, t5, t6, raw_value = ctx.comment.html, raw_before;
return {
c() {
6 years ago
div = element("div");
strong = element("strong");
t0 = text(ctx.i);
t1 = space();
6 years ago
span = element("span");
t2 = text(t2_value);
t3 = text(" wrote ");
t4 = text(t4_value);
t5 = text(" ago:");
t6 = space();
6 years ago
raw_before = element('noscript');
span.className = "meta";
div.className = "comment";
},
m(target, anchor) {
insert(target, div, anchor);
append(div, strong);
6 years ago
append(strong, t0);
append(div, t1);
append(div, span);
6 years ago
append(span, t2);
append(span, t3);
append(span, t4);
append(span, t5);
append(div, t6);
append(div, raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
},
p(changed, ctx) {
6 years ago
if ((changed.comments) && t2_value !== (t2_value = ctx.comment.author)) {
set_data(t2, t2_value);
}
6 years ago
if ((changed.elapsed || changed.comments || changed.time) && t4_value !== (t4_value = ctx.elapsed(ctx.comment.time, ctx.time))) {
set_data(t4, t4_value);
}
if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) {
6 years ago
detach_after(raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
}
},
6 years ago
d(detaching) {
if (detaching) {
detach(div);
}
}
};
}
function create_fragment(ctx) {
6 years ago
var t0, p, t1;
var each_value = ctx.comments;
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
return {
7 years ago
c() {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
8 years ago
}
t0 = space();
6 years ago
p = element("p");
t1 = text(ctx.foo);
8 years ago
},
7 years ago
m(target, anchor) {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
6 years ago
insert(target, t0, anchor);
insert(target, p, anchor);
6 years ago
append(p, t1);
},
7 years ago
p(changed, ctx) {
if (changed.comments || changed.elapsed || changed.time) {
each_value = ctx.comments;
for (var i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
7 years ago
if (each_blocks[i]) {
each_blocks[i].p(changed, child_ctx);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
6 years ago
each_blocks[i].m(t0.parentNode, t0);
}
}
for (; i < each_blocks.length; i += 1) {
7 years ago
each_blocks[i].d(1);
8 years ago
}
each_blocks.length = each_value.length;
}
if (changed.foo) {
6 years ago
set_data(t1, ctx.foo);
}
},
i: noop,
o: noop,
6 years ago
d(detaching) {
destroy_each(each_blocks, detaching);
8 years ago
6 years ago
if (detaching) {
detach(t0);
detach(p);
7 years ago
}
}
};
}
function instance($$self, $$props, $$invalidate) {
let { comments, elapsed, time, foo } = $$props;
6 years ago
$$self.$set = $$props => {
if ('comments' in $$props) $$invalidate('comments', comments = $$props.comments);
if ('elapsed' in $$props) $$invalidate('elapsed', elapsed = $$props.elapsed);
if ('time' in $$props) $$invalidate('time', time = $$props.time);
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
};
return { comments, elapsed, time, foo };
}
class Component extends SvelteComponent {
constructor(options) {
super();
6 years ago
init(this, options, instance, create_fragment, safe_not_equal, ["comments", "elapsed", "time", "foo"]);
}
}
export default Component;