diff --git a/src/core/directives/link.ts b/src/core/directives/link.ts index 37043ffc8..d9d51c659 100644 --- a/src/core/directives/link.ts +++ b/src/core/directives/link.ts @@ -140,10 +140,10 @@ export class CoreLinkDirective implements OnInit { return this.openLocalFile(href); } - if (href.charAt(0) == '#') { + if (href.charAt(0) === '#') { // Look for id or name. href = href.substring(1); - const container = this.element.closest('ion-content'); + const container = this.element.closest('ion-content'); if (container) { CoreDom.scrollToElement( container, diff --git a/src/core/singletons/dom.ts b/src/core/singletons/dom.ts index 914cc6ff2..cefd2c4bf 100644 --- a/src/core/singletons/dom.ts +++ b/src/core/singletons/dom.ts @@ -88,10 +88,11 @@ export class CoreDom { * Check whether an element is visible or not. * * @param element Element. + * @param checkSize Wether to check size to check for visibility. * @return True if element is visible inside the DOM. */ - static isElementVisible(element: HTMLElement): boolean { - if (element.clientWidth === 0 || element.clientHeight === 0) { + static isElementVisible(element: HTMLElement, checkSize = true): boolean { + if (checkSize && (element.clientWidth === 0 || element.clientHeight === 0)) { return false; } @@ -193,11 +194,10 @@ export class CoreDom { element = foundElement; } - await CoreDom.waitToBeVisible(element); + await CoreDom.waitToBeVisible(element, false); const content = element.closest('ion-content') ?? undefined; if (!content) { - // Content to scroll, not found. return false; } @@ -449,9 +449,10 @@ export class CoreDom { * Wait an element to be in dom and visible. * * @param element Element to wait. + * @param checkSize Wether to check size to check for visibility. * @return Cancellable promise. */ - static waitToBeVisible(element: HTMLElement): CoreCancellablePromise { + static waitToBeVisible(element: HTMLElement, checkSize = true): CoreCancellablePromise { const domPromise = CoreDom.waitToBeInDOM(element); let interval: number | undefined; @@ -461,12 +462,12 @@ export class CoreDom { async (resolve) => { await domPromise; - if (CoreDom.isElementVisible(element)) { + if (CoreDom.isElementVisible(element, checkSize)) { return resolve(); } interval = window.setInterval(() => { - if (!CoreDom.isElementVisible(element)) { + if (!CoreDom.isElementVisible(element, checkSize)) { return; }