Skip to content

Commit

Permalink
fix(router): rename API to match stencil-router
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Mar 13, 2018
1 parent b4f46ee commit e729610
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions core/src/components.d.ts
Expand Up @@ -2601,9 +2601,9 @@ declare global {
namespace JSXElements {
export interface IonRouteAttributes extends HTMLAttributes {
component?: string;
params?: {[key: string]: any};
path?: string;
componentProps?: {[key: string]: any};
redirectTo?: string;
url?: string;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/components/route/readme.md
Expand Up @@ -12,17 +12,17 @@
string


#### params
#### componentProps




#### path
#### redirectTo

string


#### redirectTo
#### url

string

Expand All @@ -34,17 +34,17 @@ string
string


#### params
#### component-props




#### path
#### redirect-to

string


#### redirect-to
#### url

string

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/route/route.tsx
Expand Up @@ -5,8 +5,8 @@ import { Component, Prop } from '@stencil/core';
tag: 'ion-route'
})
export class Route {
@Prop() path = '';
@Prop() url = '';
@Prop() component: string;
@Prop() redirectTo: string;
@Prop() params: {[key: string]: any};
@Prop() componentProps: {[key: string]: any};
}
12 changes: 6 additions & 6 deletions core/src/components/router/test/basic/index.html
Expand Up @@ -106,16 +106,16 @@
<ion-app>

<ion-router>
<ion-route path="/" component="tab-one"> </ion-route>
<ion-route url="/" component="tab-one"> </ion-route>

<ion-route path="/two" component="tab-two">
<ion-route url="/two" component="tab-two">
<ion-route component="page-one"> </ion-route>
<ion-route path="/second-page" component="page-two"> </ion-route>
<ion-route path="/three-page" component="page-three"> </ion-route>
<ion-route url="/second-page" component="page-two"> </ion-route>
<ion-route url="/three-page" component="page-three"> </ion-route>
</ion-route>

<ion-route path="/three" component="tab3"> </ion-route>
<ion-route path="/four" component="tab4"> </ion-route>
<ion-route url="/three" component="tab3"> </ion-route>
<ion-route url="/four" component="tab4"> </ion-route>

</ion-router>

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/router/test/parser.spec.tsx
Expand Up @@ -60,7 +60,7 @@ describe('flattenRouterTree', () => {

export function mockRouteElement(path: string, component: string) {
const el = mockElement('ion-route');
el.setAttribute('path', path);
el.setAttribute('url', path);
(el as any).component = component;
return el;
}
10 changes: 3 additions & 7 deletions core/src/components/router/utils/parser.ts
Expand Up @@ -10,7 +10,7 @@ export function readRedirects(root: Element): RouteRedirect[] {
throw new Error('Can\'t mix the component and redirectTo attribute in the same ion-route');
}
return {
path: parsePath(readProp(el, 'path')),
path: parsePath(readProp(el, 'url')),
to: parsePath(readProp(el, 'redirectTo'))
};
});
Expand All @@ -20,14 +20,10 @@ export function readRoutes(root: Element): RouteTree {
return (Array.from(root.children) as HTMLIonRouteElement[])
.filter(el => el.tagName === 'ION-ROUTE' && el.component)
.map(el => {
const path = parsePath(readProp(el, 'path'));
if (path.includes(':id')) {
console.warn('Using ":id" is not recommended in `ion-route`, it causes conflicts in the DOM');
}
return {
path: path,
path: parsePath(readProp(el, 'url')),
id: readProp(el, 'component').toLowerCase(),
params: el.params,
params: el.componentProps,
children: readRoutes(el)
};
});
Expand Down

0 comments on commit e729610

Please sign in to comment.