ion-route.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
  5. const Route = /*@__PURE__*/ proxyCustomElement(class Route extends HTMLElement {
  6. constructor() {
  7. super();
  8. this.__registerHost();
  9. this.ionRouteDataChanged = createEvent(this, "ionRouteDataChanged", 7);
  10. this.url = '';
  11. this.component = undefined;
  12. this.componentProps = undefined;
  13. this.beforeLeave = undefined;
  14. this.beforeEnter = undefined;
  15. }
  16. onUpdate(newValue) {
  17. this.ionRouteDataChanged.emit(newValue);
  18. }
  19. onComponentProps(newValue, oldValue) {
  20. if (newValue === oldValue) {
  21. return;
  22. }
  23. const keys1 = newValue ? Object.keys(newValue) : [];
  24. const keys2 = oldValue ? Object.keys(oldValue) : [];
  25. if (keys1.length !== keys2.length) {
  26. this.onUpdate(newValue);
  27. return;
  28. }
  29. for (const key of keys1) {
  30. if (newValue[key] !== oldValue[key]) {
  31. this.onUpdate(newValue);
  32. return;
  33. }
  34. }
  35. }
  36. connectedCallback() {
  37. this.ionRouteDataChanged.emit();
  38. }
  39. static get watchers() { return {
  40. "url": ["onUpdate"],
  41. "component": ["onUpdate"],
  42. "componentProps": ["onComponentProps"]
  43. }; }
  44. }, [0, "ion-route", {
  45. "url": [1],
  46. "component": [1],
  47. "componentProps": [16],
  48. "beforeLeave": [16],
  49. "beforeEnter": [16]
  50. }, undefined, {
  51. "url": ["onUpdate"],
  52. "component": ["onUpdate"],
  53. "componentProps": ["onComponentProps"]
  54. }]);
  55. function defineCustomElement$1() {
  56. if (typeof customElements === "undefined") {
  57. return;
  58. }
  59. const components = ["ion-route"];
  60. components.forEach(tagName => { switch (tagName) {
  61. case "ion-route":
  62. if (!customElements.get(tagName)) {
  63. customElements.define(tagName, Route);
  64. }
  65. break;
  66. } });
  67. }
  68. const IonRoute = Route;
  69. const defineCustomElement = defineCustomElement$1;
  70. export { IonRoute, defineCustomElement };