Skip to content

Commit

Permalink
fix(): use defineCustomElement from component
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-perkins committed Jan 4, 2022
1 parent c1d4978 commit 575f6e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 0 additions & 3 deletions core/src/utils/overlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const createController = <Opts extends object, HTMLElm extends any>(tagName: str
},
async getTop(): Promise<HTMLElm | undefined> {
return getOverlay(document, tagName) as any;
},
defineCustomElements() {
return registerOverlayComponents(tagName, customElement, childrenCustomElements);
}
};
};
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/components/IonModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { JSX, modalController } from '@ionic/core/components';
import { JSX } from '@ionic/core/components';
import { IonModal as IonModalCmp, defineCustomElement } from '@ionic/core/components/ion-modal.js';

import { createInlineOverlayComponent } from './createInlineOverlayComponent'

export const IonModal = /*@__PURE__*/ createInlineOverlayComponent<
JSX.IonModal,
HTMLIonModalElement
>('ion-modal', modalController);
>('ion-modal', IonModalCmp, defineCustomElement);
6 changes: 3 additions & 3 deletions packages/react/src/components/IonPopover.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { JSX, popoverController } from '@ionic/core/components';

import { JSX } from '@ionic/core/components';
import { IonPopover as IonPopoverCmp, defineCustomElement } from '@ionic/core/components/ion-popover.js';
import { createInlineOverlayComponent } from './createInlineOverlayComponent'

export const IonPopover = /*@__PURE__*/ createInlineOverlayComponent<
JSX.IonPopover,
HTMLIonPopoverElement
>('ion-popover', popoverController);
>('ion-popover', IonPopoverCmp, defineCustomElement);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
attachProps,
camelToDashCase,
dashToPascalCase,
defineCustomElement,
isCoveredByReact,
mergeRefs,
} from './react-component-lib/utils';
Expand All @@ -25,9 +26,13 @@ interface IonicReactInternalProps<ElementType> extends React.HTMLAttributes<Elem

export const createInlineOverlayComponent = <PropType, ElementType>(
tagName: string,
controller: { defineCustomElements: () => Promise<any> }
customElement?: any,
defineNestedCustomElements?: () => void
) => {
controller.defineCustomElements();
defineCustomElement(tagName, customElement);
if (defineNestedCustomElements) {
defineNestedCustomElements();
}

const displayName = dashToPascalCase(tagName);
const ReactComponent = class extends React.Component<IonicReactInternalProps<PropType>, InlineOverlayState> {
Expand Down

0 comments on commit 575f6e0

Please sign in to comment.