mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-21 14:55:04 +00:00
Merge branch 'master' into spread_routes
This commit is contained in:
@@ -3,7 +3,7 @@ sudo: false
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- "stable"
|
- "11"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ export async function hydrate_target(target: Target): Promise<{
|
|||||||
const j = l++;
|
const j = l++;
|
||||||
|
|
||||||
const segment = segments[i];
|
const segment = segments[i];
|
||||||
if (!session_dirty && current_branch[i] && current_branch[i].segment === segment) return current_branch[i];
|
if (!session_dirty && current_branch[i] && current_branch[i].segment === segment && current_branch[i].part === part.i) return current_branch[i];
|
||||||
|
|
||||||
const { default: component, preload } = await load_component(components[part.i]);
|
const { default: component, preload } = await load_component(components[part.i]);
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ export async function hydrate_target(target: Target): Promise<{
|
|||||||
preloaded = initial_data.preloaded[i + 1];
|
preloaded = initial_data.preloaded[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (props[`level${j}`] = { component, props: preloaded, segment });
|
return (props[`level${j}`] = { component, props: preloaded, segment, part: part.i });
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
props.error = error;
|
props.error = error;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export function get_page_handler(
|
|||||||
path: req.path,
|
path: req.path,
|
||||||
query: req.query,
|
query: req.query,
|
||||||
params: {}
|
params: {}
|
||||||
})
|
}, session)
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
match = error ? null : page.pattern.exec(req.path);
|
match = error ? null : page.pattern.exec(req.path);
|
||||||
|
|||||||
@@ -212,6 +212,6 @@ async function _export({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_href(attrs: string) {
|
function get_href(attrs: string) {
|
||||||
const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs);
|
const match = /href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
|
||||||
return match[1] || match[2] || match[3];
|
return match && (match[1] || match[2] || match[3]);
|
||||||
}
|
}
|
||||||
|
|||||||
3
test/apps/basics/src/routes/dirs/bar/[a].svelte
Normal file
3
test/apps/basics/src/routes/dirs/bar/[a].svelte
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<h1>A page</h1>
|
||||||
|
|
||||||
|
<a href="dirs/foo/xyz">same segment</a>
|
||||||
1
test/apps/basics/src/routes/dirs/foo/[b].svelte
Normal file
1
test/apps/basics/src/routes/dirs/foo/[b].svelte
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<h1>B page</h1>
|
||||||
@@ -298,6 +298,17 @@ describe('basics', function() {
|
|||||||
await page.evaluate(() => document.body.textContent),
|
await page.evaluate(() => document.body.textContent),
|
||||||
'xyz,abc,qwe'
|
'xyz,abc,qwe'
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('navigates between dynamic routes with same segments', async () => {
|
||||||
|
await page.goto(`${base}/dirs/bar/xyz`);
|
||||||
|
await start();
|
||||||
|
|
||||||
|
assert.equal(await title(), 'A page');
|
||||||
|
|
||||||
|
await page.click('[href="dirs/foo/xyz"]');
|
||||||
|
await wait(50);
|
||||||
|
assert.equal(await title(), 'B page');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs server route handlers before page handlers, if they match', async () => {
|
it('runs server route handlers before page handlers, if they match', async () => {
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
<h1>Great success!</h1>
|
<h1>Great success!</h1>
|
||||||
|
|
||||||
<a href="blog">blog</a>
|
<a href="blog">blog</a>
|
||||||
<a href="">empty anchor</a>
|
<a href="">empty anchor</a>
|
||||||
|
<a href=''>empty anchor #2</a>
|
||||||
|
<a href=>empty anchor #3</a>
|
||||||
|
<a href= >empty anchor #4</a>
|
||||||
|
<a href>empty anchor #5</a>
|
||||||
|
<a>empty anchor #6</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user