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

199 lines
4.5 KiB

/* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, append, createElement, createText, destroyEach, detachAfter, detachNode, flush, init, insert, noop, safe_not_equal, setData } 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;
}
// (1:0) {#each comments as comment, i}
function create_each_block(ctx) {
var div, strong, text0, text1, span, text2_value = ctx.comment.author, text2, text3, text4_value = ctx.elapsed(ctx.comment.time, ctx.time), text4, text5, text6, raw_value = ctx.comment.html, raw_before;
return {
c() {
div = createElement("div");
strong = createElement("strong");
text0 = createText(ctx.i);
text1 = createText("\n\n\t\t");
span = createElement("span");
text2 = createText(text2_value);
text3 = createText(" wrote ");
text4 = createText(text4_value);
text5 = createText(" ago:");
text6 = createText("\n\n\t\t");
raw_before = createElement('noscript');
span.className = "meta";
div.className = "comment";
},
m(target, anchor) {
insert(target, div, anchor);
append(div, strong);
append(strong, text0);
append(div, text1);
append(div, span);
append(span, text2);
append(span, text3);
append(span, text4);
append(span, text5);
append(div, text6);
append(div, raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
},
p(changed, ctx) {
if ((changed.comments) && text2_value !== (text2_value = ctx.comment.author)) {
setData(text2, text2_value);
}
if ((changed.elapsed || changed.comments || changed.time) && text4_value !== (text4_value = ctx.elapsed(ctx.comment.time, ctx.time))) {
setData(text4, text4_value);
}
if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) {
detachAfter(raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
}
},
d(detach) {
if (detach) {
detachNode(div);
}
}
};
}
function create_fragment(ctx) {
var text0, p, text1;
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
}
text0 = createText("\n\n");
p = createElement("p");
text1 = createText(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);
}
insert(target, text0, anchor);
insert(target, p, anchor);
append(p, text1);
},
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();
each_blocks[i].m(text0.parentNode, text0);
}
}
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) {
setData(text1, ctx.foo);
}
},
i: noop,
o: noop,
7 years ago
d(detach) {
destroyEach(each_blocks, detach);
8 years ago
7 years ago
if (detach) {
detachNode(text0);
7 years ago
detachNode(p);
}
}
};
}
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 SvelteComponent extends SvelteComponent_1 {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal);
}
get comments() {
return this.$$.ctx.comments;
}
set comments(comments) {
this.$set({ comments });
flush();
}
get elapsed() {
return this.$$.ctx.elapsed;
}
set elapsed(elapsed) {
this.$set({ elapsed });
flush();
}
get time() {
return this.$$.ctx.time;
}
set time(time) {
this.$set({ time });
flush();
}
get foo() {
return this.$$.ctx.foo;
}
8 years ago
set foo(foo) {
this.$set({ foo });
flush();
8 years ago
}
}
7 years ago
export default SvelteComponent;