diff --git a/core/src/components/datetime-button/datetime-button.tsx b/core/src/components/datetime-button/datetime-button.tsx index c42fa0edd0..68b4a7ddf0 100644 --- a/core/src/components/datetime-button/datetime-button.tsx +++ b/core/src/components/datetime-button/datetime-button.tsx @@ -75,6 +75,18 @@ export class DatetimeButton implements ComponentInterface { return; } + /** + * The element reference must be an ion-datetime. Print an error + * if a non-datetime element was provided. + */ + if (datetimeEl.tagName !== 'ION-DATETIME') { + printIonError( + `Expected an ion-datetime instance for ID '${datetime}' but received '${datetimeEl.tagName.toLowerCase()}' instead.`, + datetimeEl + ); + return; + } + /** * Since the datetime can be used in any context (overlays, accordion, etc) * we track when it is visible to determine when it is active.