|
|
|
@ -5,18 +5,18 @@ import { appendNode, assign, createElement, createText, destroyEach, detachAfter
|
|
|
|
|
function create_main_fragment(state, component) {
|
|
|
|
|
var text, p, text_1;
|
|
|
|
|
|
|
|
|
|
var each_block_value = state.comments;
|
|
|
|
|
var comments = state.comments;
|
|
|
|
|
|
|
|
|
|
var each_block_iterations = [];
|
|
|
|
|
var each_blocks = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < each_block_value.length; i += 1) {
|
|
|
|
|
each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
|
|
|
|
|
for (var i = 0; i < comments.length; i += 1) {
|
|
|
|
|
each_blocks[i] = create_each_block(state, comments, comments[i], i, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
create: function() {
|
|
|
|
|
for (var i = 0; i < each_block_iterations.length; i += 1) {
|
|
|
|
|
each_block_iterations[i].create();
|
|
|
|
|
for (var i = 0; i < each_blocks.length; i += 1) {
|
|
|
|
|
each_blocks[i].create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = createText("\n\n");
|
|
|
|
@ -25,8 +25,8 @@ function create_main_fragment(state, component) {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mount: function(target, anchor) {
|
|
|
|
|
for (var i = 0; i < each_block_iterations.length; i += 1) {
|
|
|
|
|
each_block_iterations[i].mount(target, anchor);
|
|
|
|
|
for (var i = 0; i < each_blocks.length; i += 1) {
|
|
|
|
|
each_blocks[i].mount(target, anchor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
insertNode(text, target, anchor);
|
|
|
|
@ -35,24 +35,24 @@ function create_main_fragment(state, component) {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
update: function(changed, state) {
|
|
|
|
|
var each_block_value = state.comments;
|
|
|
|
|
var comments = state.comments;
|
|
|
|
|
|
|
|
|
|
if (changed.comments || changed.elapsed || changed.time) {
|
|
|
|
|
for (var i = 0; i < each_block_value.length; i += 1) {
|
|
|
|
|
if (each_block_iterations[i]) {
|
|
|
|
|
each_block_iterations[i].update(changed, state, each_block_value, each_block_value[i], i);
|
|
|
|
|
for (var i = 0; i < comments.length; i += 1) {
|
|
|
|
|
if (each_blocks[i]) {
|
|
|
|
|
each_blocks[i].update(changed, state, comments, comments[i], i);
|
|
|
|
|
} else {
|
|
|
|
|
each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
|
|
|
|
|
each_block_iterations[i].create();
|
|
|
|
|
each_block_iterations[i].mount(text.parentNode, text);
|
|
|
|
|
each_blocks[i] = create_each_block(state, comments, comments[i], i, component);
|
|
|
|
|
each_blocks[i].create();
|
|
|
|
|
each_blocks[i].mount(text.parentNode, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (; i < each_block_iterations.length; i += 1) {
|
|
|
|
|
each_block_iterations[i].unmount();
|
|
|
|
|
each_block_iterations[i].destroy();
|
|
|
|
|
for (; i < each_blocks.length; i += 1) {
|
|
|
|
|
each_blocks[i].unmount();
|
|
|
|
|
each_blocks[i].destroy();
|
|
|
|
|
}
|
|
|
|
|
each_block_iterations.length = each_block_value.length;
|
|
|
|
|
each_blocks.length = comments.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changed.foo) {
|
|
|
|
@ -61,8 +61,8 @@ function create_main_fragment(state, component) {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unmount: function() {
|
|
|
|
|
for (var i = 0; i < each_block_iterations.length; i += 1) {
|
|
|
|
|
each_block_iterations[i].unmount();
|
|
|
|
|
for (var i = 0; i < each_blocks.length; i += 1) {
|
|
|
|
|
each_blocks[i].unmount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
detachNode(text);
|
|
|
|
@ -70,13 +70,13 @@ function create_main_fragment(state, component) {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
|
destroyEach(each_block_iterations, false, 0);
|
|
|
|
|
destroyEach(each_blocks, false, 0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// (1:0) {{#each comments as comment, i}}
|
|
|
|
|
function create_each_block(state, each_block_value, comment, i, component) {
|
|
|
|
|
function create_each_block(state, comments, comment, i, component) {
|
|
|
|
|
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 {
|
|
|
|
@ -115,7 +115,7 @@ function create_each_block(state, each_block_value, comment, i, component) {
|
|
|
|
|
raw_before.insertAdjacentHTML("afterend", raw_value);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
update: function(changed, state, each_block_value, comment, i) {
|
|
|
|
|
update: function(changed, state, comments, comment, i) {
|
|
|
|
|
if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) {
|
|
|
|
|
text_2.data = text_2_value;
|
|
|
|
|
}
|
|
|
|
|