svelte-fragment-component
Version:
Svelte component that renders its children with lifecycle hooks to simplify testing
115 lines (99 loc) • 3.23 kB
JavaScript
'use strict';
var internal = require('svelte/internal');
var Svelte = require('svelte');
/* src/fragment.svelte generated by Svelte v3.23.2 */
function create_fragment(ctx) {
let current;
const default_slot_template = /*$$slots*/ ctx[7].default;
const default_slot = internal.create_slot(default_slot_template, ctx, /*$$scope*/ ctx[6], null);
return {
c() {
if (default_slot) default_slot.c();
},
m(target, anchor) {
if (default_slot) {
default_slot.m(target, anchor);
}
current = true;
},
p(ctx, [dirty]) {
if (default_slot) {
if (default_slot.p && dirty & /*$$scope*/ 64) {
internal.update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[6], dirty, null, null);
}
}
},
i(local) {
if (current) return;
internal.transition_in(default_slot, local);
current = true;
},
o(local) {
internal.transition_out(default_slot, local);
current = false;
},
d(detaching) {
if (default_slot) default_slot.d(detaching);
}
};
}
function instance($$self, $$props, $$invalidate) {
const omit_props_names = ["context","onCreate","onMount","beforeUpdate","afterUpdate","onDestroy"];
let $$restProps = internal.compute_rest_props($$props, omit_props_names);
let { context = null } = $$props;
let { onCreate = null } = $$props;
let { onMount = null } = $$props;
let { beforeUpdate = null } = $$props;
let { afterUpdate = null } = $$props;
let { onDestroy = null } = $$props;
if (context) {
Object.keys(context).forEach(key => {
Svelte.setContext(key, context[key]);
});
}
if (onCreate) bind(onCreate)();
if (onMount) Svelte.onMount(bind(onMount));
if (beforeUpdate) Svelte.beforeUpdate(bind(beforeUpdate));
if (afterUpdate) Svelte.afterUpdate(bind(afterUpdate));
if (onDestroy) Svelte.onDestroy(bind(onDestroy));
function bind(callback) {
return () => callback({ props: $$restProps });
}
let { $$slots = {}, $$scope } = $$props;
$$self.$set = $$new_props => {
$$props = internal.assign(internal.assign({}, $$props), internal.exclude_internal_props($$new_props));
$$invalidate(9, $$restProps = internal.compute_rest_props($$props, omit_props_names));
if ("context" in $$new_props) $$invalidate(0, context = $$new_props.context);
if ("onCreate" in $$new_props) $$invalidate(1, onCreate = $$new_props.onCreate);
if ("onMount" in $$new_props) $$invalidate(2, onMount = $$new_props.onMount);
if ("beforeUpdate" in $$new_props) $$invalidate(3, beforeUpdate = $$new_props.beforeUpdate);
if ("afterUpdate" in $$new_props) $$invalidate(4, afterUpdate = $$new_props.afterUpdate);
if ("onDestroy" in $$new_props) $$invalidate(5, onDestroy = $$new_props.onDestroy);
if ("$$scope" in $$new_props) $$invalidate(6, $$scope = $$new_props.$$scope);
};
return [
context,
onCreate,
onMount,
beforeUpdate,
afterUpdate,
onDestroy,
$$scope,
$$slots
];
}
class Fragment extends internal.SvelteComponent {
constructor(options) {
super();
internal.init(this, options, instance, create_fragment, internal.safe_not_equal, {
context: 0,
onCreate: 1,
onMount: 2,
beforeUpdate: 3,
afterUpdate: 4,
onDestroy: 5
});
}
}
module.exports = Fragment;
//# sourceMappingURL=fragment.js.map