fix test after merge, move create_root_component_slots from utils.ts to Component.ts

pull/2684/head
Anton Samoylov 6 years ago
parent 8cca87cb75
commit 81285112c9

@ -1,7 +1,7 @@
import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler'; import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler';
import { current_component, set_current_component } from './lifecycle'; import { current_component, set_current_component } from './lifecycle';
import { blank_object, is_function, run, run_all, noop } from './utils'; import { blank_object, is_function, run, run_all, noop } from './utils';
import { children } from './dom'; import { children, insert, detach } from './dom';
import { transition_in } from './transitions'; import { transition_in } from './transitions';
// eslint-disable-next-line @typescript-eslint/class-name-casing // eslint-disable-next-line @typescript-eslint/class-name-casing
@ -213,3 +213,37 @@ export class SvelteComponentDev extends SvelteComponent {
}; };
} }
} }
function create_root_component_slot_fn(elements) {
return function create_root_component_slot() {
return {
c: noop,
m: function mount(target, anchor) {
elements.forEach(element => {
insert(target, element, anchor);
});
},
d: function destroy(detaching) {
if (detaching) {
elements.forEach(element => detach(element));
}
},
l: noop,
};
};
}
export function create_root_component_slots(slots) {
const root_component_slots = {};
for (const slot_name in slots) {
let elements = slots[slot_name];
if (!Array.isArray(elements)) {
elements = [elements];
}
root_component_slots[slot_name] = [create_root_component_slot_fn(elements)];
}
return root_component_slots;
}

@ -1,5 +1,3 @@
import { insert, detach } from './dom';
export function noop() {} export function noop() {}
export const identity = x => x; export const identity = x => x;
@ -83,7 +81,6 @@ export function exclude_internal_props(props) {
return result; return result;
} }
export function once(fn) { export function once(fn) {
let ran = false; let ran = false;
return function(this: any, ...args) { return function(this: any, ...args) {
@ -92,37 +89,3 @@ export function once(fn) {
fn.call(this, ...args); fn.call(this, ...args);
}; };
} }
function create_root_component_slot_fn(elements) {
return function create_root_component_slot() {
return {
c: noop,
m: function mount(target, anchor) {
elements.forEach(element => {
insert(target, element, anchor);
});
},
d: function destroy(detaching) {
if (detaching) {
elements.forEach(element => detach(element));
}
},
l: noop,
};
};
}
export function create_root_component_slots(slots) {
const root_component_slots = {};
for (const slot_name in slots) {
let elements = slots[slot_name];
if (!Array.isArray(elements)) {
elements = [elements];
}
root_component_slots[slot_name] = [create_root_component_slot_fn(elements)];
}
return root_component_slots;
}

@ -11,11 +11,13 @@ import {
init, init,
insert, insert,
safe_not_equal, safe_not_equal,
space space,
transition_in,
transition_out
} from "svelte/internal"; } from "svelte/internal";
const get_slot1_slot_changes = ({}) => ({}); const get_slot1_slot_changes = () => ({});
const get_slot1_slot_context = ({}) => ({}); const get_slot1_slot_context = () => ({});
function create_fragment(ctx) { function create_fragment(ctx) {
var div, t, current; var div, t, current;
@ -60,7 +62,7 @@ function create_fragment(ctx) {
p(changed, ctx) { p(changed, ctx) {
if (default_slot && default_slot.p && changed.$$scope) { if (default_slot && default_slot.p && changed.$$scope) {
default_slot.p(get_slot_changes(default_slot_1, ctx, changed,), get_slot_context(default_slot_1, ctx, null)); default_slot.p(get_slot_changes(default_slot_1, ctx, changed, null), get_slot_context(default_slot_1, ctx, null));
} }
if (slot1_slot && slot1_slot.p && changed.$$scope) { if (slot1_slot && slot1_slot.p && changed.$$scope) {
@ -70,14 +72,14 @@ function create_fragment(ctx) {
i(local) { i(local) {
if (current) return; if (current) return;
if (default_slot && default_slot.i) default_slot.i(local); transition_in(default_slot, local);
if (slot1_slot && slot1_slot.i) slot1_slot.i(local); transition_in(slot1_slot, local);
current = true; current = true;
}, },
o(local) { o(local) {
if (default_slot && default_slot.o) default_slot.o(local); transition_out(default_slot, local);
if (slot1_slot && slot1_slot.o) slot1_slot.o(local); transition_out(slot1_slot, local);
current = false; current = false;
}, },

Loading…
Cancel
Save