UNPKG

svelte4-fragment-component

Version:

Svelte component that renders its children with lifecycle hooks to simplify testing using svelte4

113 lines (98 loc) 3.35 kB
import { SvelteComponent, init, safe_not_equal, create_slot, update_slot, transition_in, transition_out, compute_rest_props, assign, exclude_internal_props } from 'svelte/internal'; import { setContext, onMount, beforeUpdate, afterUpdate, onDestroy } from '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 = 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) { update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[6], dirty, null, null); } } }, i(local) { if (current) return; transition_in(default_slot, local); current = true; }, o(local) { 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 = compute_rest_props($$props, omit_props_names); let { context = null } = $$props; let { onCreate = null } = $$props; let { onMount: onMount$1 = null } = $$props; let { beforeUpdate: beforeUpdate$1 = null } = $$props; let { afterUpdate: afterUpdate$1 = null } = $$props; let { onDestroy: onDestroy$1 = null } = $$props; if (context) { Object.keys(context).forEach(key => { setContext(key, context[key]); }); } if (onCreate) bind(onCreate)(); if (onMount$1) onMount(bind(onMount$1)); if (beforeUpdate$1) beforeUpdate(bind(beforeUpdate$1)); if (afterUpdate$1) afterUpdate(bind(afterUpdate$1)); if (onDestroy$1) onDestroy(bind(onDestroy$1)); function bind(callback) { return () => callback({ props: $$restProps }); } let { $$slots = {}, $$scope } = $$props; $$self.$set = $$new_props => { $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)); $$invalidate(9, $$restProps = 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$1 = $$new_props.onMount); if ("beforeUpdate" in $$new_props) $$invalidate(3, beforeUpdate$1 = $$new_props.beforeUpdate); if ("afterUpdate" in $$new_props) $$invalidate(4, afterUpdate$1 = $$new_props.afterUpdate); if ("onDestroy" in $$new_props) $$invalidate(5, onDestroy$1 = $$new_props.onDestroy); if ("$$scope" in $$new_props) $$invalidate(6, $$scope = $$new_props.$$scope); }; return [ context, onCreate, onMount$1, beforeUpdate$1, afterUpdate$1, onDestroy$1, $$scope, $$slots ]; } class Fragment extends SvelteComponent { constructor(options) { super(); init(this, options, instance, create_fragment, safe_not_equal, { context: 0, onCreate: 1, onMount: 2, beforeUpdate: 3, afterUpdate: 4, onDestroy: 5 }); } } export default Fragment; //# sourceMappingURL=fragment.js.map