@bjornlu/svelte-router
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -17,2 +17,10 @@ import { Readable } from 'svelte/store'; | ||
constructor(routes: RouteRecord[]); | ||
/** | ||
* Navigates to the url but do not create a new entry in the history | ||
*/ | ||
protected abstract replace(url: string): void; | ||
/** | ||
* Navigates to the url, leaving behind a trace in the history | ||
*/ | ||
protected abstract push(url: string): void; | ||
protected abstract getCurrentPath(): string; | ||
@@ -19,0 +27,0 @@ protected abstract getCurrentLocationInput(): LocationInput; |
@@ -26,6 +26,6 @@ import { readable, derived } from 'svelte/store'; | ||
if (replace) { | ||
history.replaceState(url, '', url); | ||
this.replace(url); | ||
} | ||
else { | ||
history.pushState(url, '', url); | ||
this.push(url); | ||
} | ||
@@ -32,0 +32,0 @@ } |
@@ -14,2 +14,4 @@ import { Router } from './base'; | ||
}; | ||
replace(url: string): void; | ||
push(url: string): void; | ||
} |
@@ -49,2 +49,8 @@ import { get } from 'svelte/store'; | ||
} | ||
replace(url) { | ||
location.replace(url); | ||
} | ||
push(url) { | ||
location.assign(url); | ||
} | ||
} |
@@ -14,2 +14,4 @@ import { Router } from './base'; | ||
}; | ||
replace(url: string): void; | ||
push(url: string): void; | ||
} |
@@ -46,2 +46,8 @@ import { get } from 'svelte/store'; | ||
} | ||
replace(url) { | ||
history.replaceState(url, '', url); | ||
} | ||
push(url) { | ||
history.pushState(url, '', url); | ||
} | ||
} |
@@ -58,5 +58,2 @@ (function (global, factory) { | ||
} | ||
function is_empty(obj) { | ||
return Object.keys(obj).length === 0; | ||
} | ||
function subscribe(store, ...callbacks) { | ||
@@ -106,9 +103,2 @@ 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) { | ||
@@ -164,6 +154,3 @@ const result = {}; | ||
} | ||
else if (key === '__value') { | ||
node.value = node[key] = attributes[key]; | ||
} | ||
else if (descriptors[key] && descriptors[key].set) { | ||
else if (key === '__value' || descriptors[key] && descriptors[key].set) { | ||
node[key] = attributes[key]; | ||
@@ -221,3 +208,2 @@ } | ||
} | ||
set_current_component(null); | ||
dirty_components.length = 0; | ||
@@ -387,4 +373,3 @@ while (binding_callbacks.length) | ||
callbacks: blank_object(), | ||
dirty, | ||
skip_bound: false | ||
dirty | ||
}; | ||
@@ -396,3 +381,3 @@ let ready = false; | ||
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { | ||
if (!$$.skip_bound && $$.bound[i]) | ||
if ($$.bound[i]) | ||
$$.bound[i](value); | ||
@@ -428,5 +413,2 @@ if (ready) | ||
} | ||
/** | ||
* Base class for Svelte components. Used when dev=false. | ||
*/ | ||
class SvelteComponent { | ||
@@ -446,8 +428,4 @@ $destroy() { | ||
} | ||
$set($$props) { | ||
if (this.$$set && !is_empty($$props)) { | ||
this.$$.skip_bound = true; | ||
this.$$set($$props); | ||
this.$$.skip_bound = false; | ||
} | ||
$set() { | ||
// overridden by instance, if it has props | ||
} | ||
@@ -464,3 +442,3 @@ } | ||
return { | ||
subscribe: writable(value, start).subscribe | ||
subscribe: writable(value, start).subscribe, | ||
}; | ||
@@ -726,6 +704,6 @@ } | ||
if (replace) { | ||
history.replaceState(url, '', url); | ||
this.replace(url); | ||
} | ||
else { | ||
history.pushState(url, '', url); | ||
this.push(url); | ||
} | ||
@@ -815,2 +793,8 @@ } | ||
} | ||
replace(url) { | ||
location.replace(url); | ||
} | ||
push(url) { | ||
location.assign(url); | ||
} | ||
} | ||
@@ -860,2 +844,8 @@ | ||
} | ||
replace(url) { | ||
history.replaceState(url, '', url); | ||
} | ||
push(url) { | ||
history.pushState(url, '', url); | ||
} | ||
} | ||
@@ -906,3 +896,3 @@ | ||
/* dist/components/RouterView.svelte generated by Svelte v3.31.2 */ | ||
/* dist/components/RouterView.svelte generated by Svelte v3.20.0 */ | ||
@@ -965,4 +955,2 @@ function create_if_block(ctx) { | ||
if_block.c(); | ||
} else { | ||
if_block.p(ctx, dirty); | ||
} | ||
@@ -998,5 +986,4 @@ | ||
function create_if_block_3(ctx) { | ||
let routerview; | ||
let current; | ||
routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
@@ -1033,3 +1020,2 @@ return { | ||
function create_if_block_1(ctx) { | ||
let switch_instance; | ||
let switch_instance_anchor; | ||
@@ -1049,3 +1035,3 @@ let current; | ||
if (switch_value) { | ||
switch_instance = new switch_value(switch_props(ctx)); | ||
var switch_instance = new switch_value(switch_props(ctx)); | ||
} | ||
@@ -1115,5 +1101,4 @@ | ||
function create_if_block_2(ctx) { | ||
let routerview; | ||
let current; | ||
routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
const routerview = new RouterView({ props: { depth: /*depth*/ ctx[0] + 1 } }); | ||
@@ -1168,6 +1153,3 @@ return { | ||
if_block.p(ctx, dirty); | ||
if (dirty & /*hasChildren*/ 8) { | ||
transition_in(if_block, 1); | ||
} | ||
transition_in(if_block, 1); | ||
} else { | ||
@@ -1224,6 +1206,3 @@ if_block = create_if_block_2(ctx); | ||
if_block.p(ctx, dirty); | ||
if (dirty & /*canRender*/ 2) { | ||
transition_in(if_block, 1); | ||
} | ||
transition_in(if_block, 1); | ||
} else { | ||
@@ -1262,4 +1241,2 @@ if_block = create_if_block(ctx); | ||
function instance($$self, $$props, $$invalidate) { | ||
let match; | ||
let hasChildren; | ||
let $route; | ||
@@ -1271,6 +1248,9 @@ 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 = () => { | ||
@@ -1320,3 +1300,3 @@ if ($$self.$$.dirty & /*$route, depth*/ 33) { | ||
return [depth, canRender, component, hasChildren, match, $route]; | ||
return [depth, canRender, component, hasChildren]; | ||
} | ||
@@ -1331,12 +1311,9 @@ | ||
/* dist/components/Link.svelte generated by Svelte v3.31.2 */ | ||
/* dist/components/Link.svelte generated by Svelte v3.20.0 */ | ||
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); | ||
@@ -1346,7 +1323,5 @@ | ||
/*$$restProps*/ ctx[3], | ||
{ href: /*$link*/ ctx[1].href }, | ||
{ | ||
href: a_href_value = /*$link*/ ctx[1].href | ||
}, | ||
{ | ||
"aria-current": a_aria_current_value = /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
} | ||
@@ -1369,3 +1344,3 @@ ]; | ||
}, | ||
m(target, anchor) { | ||
m(target, anchor, remount) { | ||
insert(target, a, anchor); | ||
@@ -1378,7 +1353,4 @@ | ||
current = true; | ||
if (!mounted) { | ||
dispose = listen(a, "click", /*handleClick*/ ctx[2]); | ||
mounted = true; | ||
} | ||
if (remount) dispose(); | ||
dispose = listen(a, "click", /*handleClick*/ ctx[2]); | ||
}, | ||
@@ -1388,10 +1360,12 @@ p(ctx, [dirty]) { | ||
if (default_slot.p && dirty & /*$$scope*/ 64) { | ||
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[6], dirty, null, null); | ||
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)); | ||
} | ||
} | ||
set_attributes(a, a_data = get_spread_update(a_levels, [ | ||
set_attributes(a, get_spread_update(a_levels, [ | ||
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3], | ||
(!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 } | ||
dirty & /*$link*/ 2 && { href: /*$link*/ ctx[1].href }, | ||
dirty & /*$link, undefined*/ 2 && { | ||
"aria-current": /*$link*/ ctx[1].isExactActive ? "page" : undefined | ||
} | ||
])); | ||
@@ -1414,3 +1388,2 @@ | ||
if (default_slot) default_slot.d(detaching); | ||
mounted = false; | ||
dispose(); | ||
@@ -1422,3 +1395,2 @@ } | ||
function instance$1($$self, $$props, $$invalidate) { | ||
let link; | ||
const omit_props_names = ["to","replace"]; | ||
@@ -1432,3 +1404,2 @@ let $$restProps = compute_rest_props($$props, omit_props_names); | ||
$$self.$$.on_destroy.push(() => $$unsubscribe_link()); | ||
let { $$slots: slots = {}, $$scope } = $$props; | ||
@@ -1447,3 +1418,5 @@ let { to } = $$props; | ||
$$self.$$set = $$new_props => { | ||
let { $$slots = {}, $$scope } = $$props; | ||
$$self.$set = $$new_props => { | ||
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props)); | ||
@@ -1456,2 +1429,4 @@ $$invalidate(3, $$restProps = compute_rest_props($$props, omit_props_names)); | ||
let link; | ||
$$self.$$.update = () => { | ||
@@ -1463,3 +1438,3 @@ if ($$self.$$.dirty & /*to*/ 16) { | ||
return [link, $link, handleClick, $$restProps, to, replace, $$scope, slots]; | ||
return [link, $link, handleClick, $$restProps, to, replace, $$scope, $$slots]; | ||
} | ||
@@ -1466,0 +1441,0 @@ |
{ | ||
"name": "@bjornlu/svelte-router", | ||
"description": "An easy-to-use SPA router for Svelte", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"main": "dist/svelte-router.umd.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.js", |
Sorry, the diff of this file is not supported yet
72508
24
1854