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

170 lines
4.2 KiB

/* generated by Svelte vX.Y.Z */
import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment(component, state) {
var text, p, text_1;
var each_value = state.comments;
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(component, assign(assign({}, state), {
each_value: each_value,
comment: each_value[i],
i: i
}));
}
return {
c: function create() {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
text = createText("\n\n");
p = createElement("p");
text_1 = createText(state.foo);
},
m: function mount(target, anchor) {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insertNode(text, target, anchor);
insertNode(p, target, anchor);
appendNode(text_1, p);
},
p: function update(changed, state) {
var each_value = state.comments;
if (changed.comments || changed.elapsed || changed.time) {
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign(assign({}, state), {
each_value: each_value,
comment: each_value[i],
i: i
});
if (each_blocks[i]) {
each_blocks[i].p(changed, each_context);
} else {
each_blocks[i] = create_each_block(component, each_context);
each_blocks[i].c();
each_blocks[i].m(text.parentNode, text);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].u();
each_blocks[i].d();
}
each_blocks.length = each_value.length;
}
if (changed.foo) {
text_1.data = state.foo;
}
},
u: function unmount() {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].u();
}
detachNode(text);
detachNode(p);
},
d: function destroy() {
destroyEach(each_blocks);
}
};
}
// (1:0) {{#each comments as comment, i}}
function create_each_block(component, state) {
var comment = state.comment, each_value = state.each_value, i = state.i;
var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before;
return {
c: function create() {
div = createElement("div");
strong = createElement("strong");
text = createText(i);
text_1 = createText("\n\n\t\t");
span = createElement("span");
text_2 = createText(text_2_value);
text_3 = createText(" wrote ");
text_4 = createText(text_4_value);
text_5 = createText(" ago:");
text_6 = createText("\n\n\t\t");
raw_before = createElement('noscript');
this.h();
},
h: function hydrate() {
span.className = "meta";
div.className = "comment";
},
m: function mount(target, anchor) {
insertNode(div, target, anchor);
appendNode(strong, div);
appendNode(text, strong);
appendNode(text_1, div);
appendNode(span, div);
appendNode(text_2, span);
appendNode(text_3, span);
appendNode(text_4, span);
appendNode(text_5, span);
appendNode(text_6, div);
appendNode(raw_before, div);
raw_before.insertAdjacentHTML("afterend", raw_value);
},
p: function update(changed, state) {
comment = state.comment;
each_value = state.each_value;
i = state.i;
if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) {
text_2.data = text_2_value;
}
if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) {
text_4.data = text_4_value;
}
if ((changed.comments) && raw_value !== (raw_value = comment.html)) {
detachAfter(raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
}
},
u: function unmount() {
detachAfter(raw_before);
detachNode(div);
},
d: noop
};
}
function SvelteComponent(options) {
init(this, options);
this._state = assign({}, options.data);
this._fragment = create_main_fragment(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
}
}
assign(SvelteComponent.prototype, proto);
export default SvelteComponent;