projecte_ionic/node_modules/@ionic/core/components/ion-route.js
2022-02-09 18:30:03 +01:00

49 lines
1.4 KiB
JavaScript
Executable file

import { createEvent, proxyCustomElement } from '@stencil/core/internal/client';
const Route = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.ionRouteDataChanged = createEvent(this, "ionRouteDataChanged", 7);
/**
* Relative path that needs to match in order for this route to apply.
*
* Accepts paths similar to expressjs so that you can define parameters
* in the url /foo/:bar where bar would be available in incoming props.
*/
this.url = '';
}
onUpdate(newValue) {
this.ionRouteDataChanged.emit(newValue);
}
onComponentProps(newValue, oldValue) {
if (newValue === oldValue) {
return;
}
const keys1 = newValue ? Object.keys(newValue) : [];
const keys2 = oldValue ? Object.keys(oldValue) : [];
if (keys1.length !== keys2.length) {
this.onUpdate(newValue);
return;
}
for (const key of keys1) {
if (newValue[key] !== oldValue[key]) {
this.onUpdate(newValue);
return;
}
}
}
connectedCallback() {
this.ionRouteDataChanged.emit();
}
static get watchers() { return {
"url": ["onUpdate"],
"component": ["onUpdate"],
"componentProps": ["onComponentProps"]
}; }
};
const IonRoute = /*@__PURE__*/proxyCustomElement(Route, [0,"ion-route",{"url":[1],"component":[1],"componentProps":[16],"beforeLeave":[16],"beforeEnter":[16]}]);
export { IonRoute };