mirror of https://github.com/sveltejs/svelte
parent
0fbcda12aa
commit
26e53cc549
@ -1,205 +0,0 @@
|
|||||||
/* generated by Svelte vX.Y.Z */
|
|
||||||
import {
|
|
||||||
SvelteComponent,
|
|
||||||
append,
|
|
||||||
destroy_each,
|
|
||||||
detach,
|
|
||||||
element,
|
|
||||||
init,
|
|
||||||
insert,
|
|
||||||
noop,
|
|
||||||
safe_not_equal,
|
|
||||||
space,
|
|
||||||
text
|
|
||||||
} from "svelte/internal";
|
|
||||||
|
|
||||||
function get_each_context(ctx, list, i) {
|
|
||||||
const child_ctx = Object.create(ctx);
|
|
||||||
child_ctx.char = list[i];
|
|
||||||
return child_ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_each_context_1(ctx, list, i) {
|
|
||||||
const child_ctx = Object.create(ctx);
|
|
||||||
child_ctx.char = list[i];
|
|
||||||
return child_ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (6:4) {#each message as char}
|
|
||||||
function create_each_block_1(ctx) {
|
|
||||||
var span, t0_value = ctx.char, t0, t1;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
span = element("span");
|
|
||||||
t0 = text(t0_value);
|
|
||||||
t1 = space();
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insert(target, span, anchor);
|
|
||||||
append(span, t0);
|
|
||||||
append(span, t1);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
d(detaching) {
|
|
||||||
if (detaching) {
|
|
||||||
detach(span);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// (12:4) {#each message as char}
|
|
||||||
function create_each_block(ctx) {
|
|
||||||
var span, t0_value = ctx.char, t0, t1;
|
|
||||||
|
|
||||||
return {
|
|
||||||
c() {
|
|
||||||
span = element("span");
|
|
||||||
t0 = text(t0_value);
|
|
||||||
t1 = space();
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insert(target, span, anchor);
|
|
||||||
append(span, t0);
|
|
||||||
append(span, t1);
|
|
||||||
},
|
|
||||||
|
|
||||||
p: noop,
|
|
||||||
|
|
||||||
d(detaching) {
|
|
||||||
if (detaching) {
|
|
||||||
detach(span);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_fragment(ctx) {
|
|
||||||
var div0, t, div1;
|
|
||||||
|
|
||||||
var each_value_1 = message;
|
|
||||||
|
|
||||||
var each_blocks_1 = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < each_value_1.length; i += 1) {
|
|
||||||
each_blocks_1[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
var each_value = message;
|
|
||||||
|
|
||||||
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 {
|
|
||||||
c() {
|
|
||||||
div0 = element("div");
|
|
||||||
|
|
||||||
for (var i = 0; i < each_blocks_1.length; i += 1) {
|
|
||||||
each_blocks_1[i].c();
|
|
||||||
}
|
|
||||||
|
|
||||||
t = space();
|
|
||||||
div1 = element("div");
|
|
||||||
|
|
||||||
for (var i = 0; i < each_blocks.length; i += 1) {
|
|
||||||
each_blocks[i].c();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
m(target, anchor) {
|
|
||||||
insert(target, div0, anchor);
|
|
||||||
|
|
||||||
for (var i = 0; i < each_blocks_1.length; i += 1) {
|
|
||||||
each_blocks_1[i].m(div0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
insert(target, t, anchor);
|
|
||||||
insert(target, div1, anchor);
|
|
||||||
|
|
||||||
for (var i = 0; i < each_blocks.length; i += 1) {
|
|
||||||
each_blocks[i].m(div1, null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
p(changed, ctx) {
|
|
||||||
if (changed.message) {
|
|
||||||
each_value_1 = message;
|
|
||||||
|
|
||||||
for (var i = 0; i < each_value_1.length; i += 1) {
|
|
||||||
const child_ctx = get_each_context_1(ctx, each_value_1, i);
|
|
||||||
|
|
||||||
if (each_blocks_1[i]) {
|
|
||||||
each_blocks_1[i].p(changed, child_ctx);
|
|
||||||
} else {
|
|
||||||
each_blocks_1[i] = create_each_block_1(child_ctx);
|
|
||||||
each_blocks_1[i].c();
|
|
||||||
each_blocks_1[i].m(div0, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; i < each_blocks_1.length; i += 1) {
|
|
||||||
each_blocks_1[i].d(1);
|
|
||||||
}
|
|
||||||
each_blocks_1.length = each_value_1.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed.message) {
|
|
||||||
each_value = message;
|
|
||||||
|
|
||||||
for (var i = 0; i < each_value.length; i += 1) {
|
|
||||||
const child_ctx = get_each_context(ctx, each_value, i);
|
|
||||||
|
|
||||||
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(div1, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; i < each_blocks.length; i += 1) {
|
|
||||||
each_blocks[i].d(1);
|
|
||||||
}
|
|
||||||
each_blocks.length = each_value.length;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
i: noop,
|
|
||||||
o: noop,
|
|
||||||
|
|
||||||
d(detaching) {
|
|
||||||
if (detaching) {
|
|
||||||
detach(div0);
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy_each(each_blocks_1, detaching);
|
|
||||||
|
|
||||||
if (detaching) {
|
|
||||||
detach(t);
|
|
||||||
detach(div1);
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy_each(each_blocks, detaching);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let message = "the quick brown fox jumps over the lazy dog"
|
|
||||||
|
|
||||||
class Component extends SvelteComponent {
|
|
||||||
constructor(options) {
|
|
||||||
super();
|
|
||||||
init(this, options, null, create_fragment, safe_not_equal, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Component;
|
|
@ -0,0 +1,16 @@
|
|||||||
|
const message = "the quick brown fox jumps over the lazy dog";
|
||||||
|
const expected = [...message].map(c => `<span>${c + " "}</span>`).join("");
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
message
|
||||||
|
},
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const firstSpanList = target.children[0];
|
||||||
|
assert.equal(firstSpanList.innerHTML, expected);
|
||||||
|
|
||||||
|
const secondSpanList = target.children[1];
|
||||||
|
assert.equal(secondSpanList.innerHTML, expected);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in new issue