@bjornlu/svelte-router
Advanced tools
Comparing version 0.4.0 to 0.4.1
# Changelog | ||
## 0.4.1 - 2021-01-31 | ||
### Fixed | ||
- Don't remount component when enter nested routes (again) | ||
## 0.4.0 - 2021-01-30 | ||
### Fixed | ||
- Don't remount component when enter nested routes | ||
## 0.3.2 - 2020-10-11 | ||
@@ -4,0 +16,0 @@ |
@@ -55,2 +55,8 @@ (function (global, factory) { | ||
} | ||
function not_equal(a, b) { | ||
return a != a ? b == b : a !== b; | ||
} | ||
function is_empty(obj) { | ||
return Object.keys(obj).length === 0; | ||
} | ||
function subscribe(store, ...callbacks) { | ||
@@ -100,2 +106,9 @@ if (store == null) { | ||
} | ||
function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) { | ||
const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn); | ||
if (slot_changes) { | ||
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn); | ||
slot.p(slot_context, slot_changes); | ||
} | ||
} | ||
function exclude_internal_props(props) { | ||
@@ -151,3 +164,6 @@ const result = {}; | ||
} | ||
else if (key === '__value' || descriptors[key] && descriptors[key].set) { | ||
else if (key === '__value') { | ||
node.value = node[key] = attributes[key]; | ||
} | ||
else if (descriptors[key] && descriptors[key].set) { | ||
node[key] = attributes[key]; | ||
@@ -205,2 +221,3 @@ } | ||
} | ||
set_current_component(null); | ||
dirty_components.length = 0; | ||
@@ -370,3 +387,4 @@ while (binding_callbacks.length) | ||
callbacks: blank_object(), | ||
dirty | ||
dirty, | ||
skip_bound: false | ||
}; | ||
@@ -378,3 +396,3 @@ let ready = false; | ||
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { | ||
if ($$.bound[i]) | ||
if (!$$.skip_bound && $$.bound[i]) | ||
$$.bound[i](value); | ||
@@ -410,2 +428,5 @@ if (ready) | ||
} | ||
/** | ||
* Base class for Svelte components. Used when dev=false. | ||
*/ | ||
class SvelteComponent { | ||
@@ -425,4 +446,8 @@ $destroy() { | ||
} | ||
$set() { | ||
// overridden by instance, if it has props | ||
$set($$props) { | ||
if (this.$$set && !is_empty($$props)) { | ||
this.$$.skip_bound = true; | ||
this.$$set($$props); | ||
this.$$.skip_bound = false; | ||
} | ||
} | ||
@@ -439,3 +464,3 @@ } | ||
return { | ||
subscribe: writable(value, start).subscribe, | ||
subscribe: writable(value, start).subscribe | ||
}; | ||
@@ -878,3 +903,3 @@ } | ||
/* dist/components/RouterView.svelte generated by Svelte v3.20.0 */ | ||
/* dist/components/RouterView.svelte generated by Svelte v3.31.2 */ | ||
@@ -937,2 +962,4 @@ function create_if_block(ctx) { | ||
if_block.c(); | ||
} else { | ||
if_block.p(ctx, dirty); | ||
} | ||
@@ -966,6 +993,7 @@ | ||
// (35:24) | ||
// (37:24) | ||
function create_if_block_3(ctx) { | ||
let routerview; | ||
let current; | ||
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
@@ -1000,4 +1028,5 @@ return { | ||
// (29:2) {#if component != null} | ||
// (31:2) {#if component != null} | ||
function create_if_block_1(ctx) { | ||
let switch_instance; | ||
let switch_instance_anchor; | ||
@@ -1017,3 +1046,3 @@ let current; | ||
if (switch_value) { | ||
var switch_instance = new switch_value(switch_props(ctx)); | ||
switch_instance = new switch_value(switch_props(ctx)); | ||
} | ||
@@ -1081,6 +1110,7 @@ | ||
// (31:6) {#if hasChildren} | ||
// (33:6) {#if hasChildren} | ||
function create_if_block_2(ctx) { | ||
let routerview; | ||
let current; | ||
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
@@ -1115,3 +1145,3 @@ return { | ||
// (30:4) <svelte:component this={component}> | ||
// (32:4) <svelte:component this={component}> | ||
function create_default_slot(ctx) { | ||
@@ -1136,3 +1166,6 @@ let if_block_anchor; | ||
if_block.p(ctx, dirty); | ||
transition_in(if_block, 1); | ||
if (dirty & /*hasChildren*/ 8) { | ||
transition_in(if_block, 1); | ||
} | ||
} else { | ||
@@ -1189,3 +1222,6 @@ if_block = create_if_block_2(ctx); | ||
if_block.p(ctx, dirty); | ||
transition_in(if_block, 1); | ||
if (dirty & /*canRender*/ 2) { | ||
transition_in(if_block, 1); | ||
} | ||
} else { | ||
@@ -1224,2 +1260,4 @@ if_block = create_if_block(ctx); | ||
function instance($$self, $$props, $$invalidate) { | ||
let match; | ||
let hasChildren; | ||
let $route; | ||
@@ -1231,9 +1269,6 @@ component_subscribe($$self, route, $$value => $$invalidate(5, $route = $$value)); | ||
$$self.$set = $$props => { | ||
$$self.$$set = $$props => { | ||
if ("depth" in $$props) $$invalidate(0, depth = $$props.depth); | ||
}; | ||
let match; | ||
let hasChildren; | ||
$$self.$$.update = () => { | ||
@@ -1283,3 +1318,3 @@ if ($$self.$$.dirty & /*$route, depth*/ 33) { | ||
return [depth, canRender, component, hasChildren]; | ||
return [depth, canRender, component, hasChildren, match, $route]; | ||
} | ||
@@ -1290,13 +1325,16 @@ | ||
super(); | ||
init(this, options, instance, create_fragment, safe_not_equal, { depth: 0 }); | ||
init(this, options, instance, create_fragment, not_equal, { depth: 0 }); | ||
} | ||
} | ||
/* dist/components/Link.svelte generated by Svelte v3.20.0 */ | ||
/* dist/components/Link.svelte generated by Svelte v3.31.2 */ | ||
function create_fragment$1(ctx) { | ||
let a; | ||
let a_href_value; | ||
let a_aria_current_value; | ||
let current; | ||
let mounted; | ||
let dispose; | ||
const default_slot_template = /*$$slots*/ ctx[7].default; | ||
const default_slot_template = /*#slots*/ ctx[7].default; | ||
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[6], null); | ||
@@ -1306,5 +1344,7 @@ | ||
/*$$restProps*/ ctx[3], | ||
{ href: /*$link*/ ctx[1].href }, | ||
{ | ||
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
href: a_href_value = /*$link*/ ctx[1].href | ||
}, | ||
{ | ||
"aria-current": a_aria_current_value = /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
} | ||
@@ -1327,3 +1367,3 @@ ]; | ||
}, | ||
m(target, anchor, remount) { | ||
m(target, anchor) { | ||
insert(target, a, anchor); | ||
@@ -1336,4 +1376,7 @@ | ||
current = true; | ||
if (remount) dispose(); | ||
dispose = listen(a, "click", /*handleClick*/ ctx[2]); | ||
if (!mounted) { | ||
dispose = listen(a, "click", /*handleClick*/ ctx[2]); | ||
mounted = true; | ||
} | ||
}, | ||
@@ -1343,12 +1386,10 @@ p(ctx, [dirty]) { | ||
if (default_slot.p && dirty & /*$$scope*/ 64) { | ||
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[6], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[6], dirty, null)); | ||
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[6], dirty, null, null); | ||
} | ||
} | ||
set_attributes(a, get_spread_update(a_levels, [ | ||
set_attributes(a, a_data = get_spread_update(a_levels, [ | ||
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3], | ||
dirty & /*$link*/ 2 && { href: /*$link*/ ctx[1].href }, | ||
dirty & /*$link, undefined*/ 2 && { | ||
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
} | ||
(!current || dirty & /*$link*/ 2 && a_href_value !== (a_href_value = /*$link*/ ctx[1].href)) && { href: a_href_value }, | ||
(!current || dirty & /*$link*/ 2 && a_aria_current_value !== (a_aria_current_value = /*$link*/ ctx[1].isExactActive ? "page" : undefined)) && { "aria-current": a_aria_current_value } | ||
])); | ||
@@ -1371,2 +1412,3 @@ | ||
if (default_slot) default_slot.d(detaching); | ||
mounted = false; | ||
dispose(); | ||
@@ -1378,2 +1420,3 @@ } | ||
function instance$1($$self, $$props, $$invalidate) { | ||
let link; | ||
const omit_props_names = ["to","replace"]; | ||
@@ -1387,2 +1430,3 @@ let $$restProps = compute_rest_props($$props, omit_props_names); | ||
$$self.$$.on_destroy.push(() => $$unsubscribe_link()); | ||
let { $$slots: slots = {}, $$scope } = $$props; | ||
@@ -1401,5 +1445,3 @@ let { to } = $$props; | ||
let { $$slots = {}, $$scope } = $$props; | ||
$$self.$set = $$new_props => { | ||
$$self.$$set = $$new_props => { | ||
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props)); | ||
@@ -1412,4 +1454,2 @@ $$invalidate(3, $$restProps = compute_rest_props($$props, omit_props_names)); | ||
let link; | ||
$$self.$$.update = () => { | ||
@@ -1421,3 +1461,3 @@ if ($$self.$$.dirty & /*to*/ 16) { | ||
return [link, $link, handleClick, $$restProps, to, replace, $$scope, $$slots]; | ||
return [link, $link, handleClick, $$restProps, to, replace, $$scope, slots]; | ||
} | ||
@@ -1424,0 +1464,0 @@ |
{ | ||
"name": "@bjornlu/svelte-router", | ||
"description": "An easy-to-use SPA router for Svelte", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main": "dist/svelte-router.umd.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.js", |
Sorry, the diff of this file is not supported yet
74587
1855