Skip to content

Commit bc7c5a9

Browse files
CR
1 parent c13ed33 commit bc7c5a9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

core/src/components/segment-button/segment-button.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ComponentInterface } from '@stencil/core';
22
import { Component, Element, Host, Prop, Method, State, Watch, forceUpdate, h } from '@stencil/core';
33
import type { ButtonInterface } from '@utils/element-interface';
44
import type { Attributes } from '@utils/helpers';
5-
import { addEventListener, removeEventListener, inheritAttributes } from '@utils/helpers';
5+
import { addEventListener, removeEventListener, inheritAttributes, getNextSiblingOfType } from '@utils/helpers';
66
import { hostContext } from '@utils/theme';
77

88
import { getIonMode } from '../../global/ionic-global';
@@ -65,17 +65,6 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
6565
this.updateState();
6666
}
6767

68-
private getNextSiblingOfType<T extends Element>(element: Element): T | null {
69-
let sibling = element.nextSibling;
70-
while (sibling) {
71-
if (sibling.nodeType === Node.ELEMENT_NODE && (sibling as T) !== null) {
72-
return sibling as T;
73-
}
74-
sibling = sibling.nextSibling;
75-
}
76-
return null;
77-
}
78-
7968
private waitForSegmentContent(ionSegment: HTMLIonSegmentElement | null, contentId: string): Promise<HTMLElement> {
8069
return new Promise((resolve, reject) => {
8170
let timeoutId: NodeJS.Timeout | undefined = undefined;
@@ -87,7 +76,7 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
8776
return;
8877
}
8978

90-
const segmentView = this.getNextSiblingOfType<HTMLIonSegmentViewElement>(ionSegment); // Skip the text nodes
79+
const segmentView = getNextSiblingOfType<HTMLIonSegmentViewElement>(ionSegment); // Skip the text nodes
9180
const segmentContent = segmentView?.querySelector(
9281
`ion-segment-content[id="${contentId}"]`
9382
) as HTMLIonSegmentContentElement | null;

core/src/utils/helpers.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const transitionEndAsync = (el: HTMLElement | null, expectedDuration = 0)
2222
*/
2323
const transitionEnd = (el: HTMLElement | null, expectedDuration = 0, callback: (ev?: TransitionEvent) => void) => {
2424
let unRegTrans: (() => void) | undefined;
25-
let animationTimeout: number | undefined;
25+
let animationTimeout: NodeJS.Timeout | undefined;
2626
const opts: AddEventListenerOptions = { passive: true };
2727
const ANIMATION_FALLBACK_TIMEOUT = 500;
2828

@@ -413,3 +413,14 @@ export const shallowEqualStringMap = (
413413

414414
return true;
415415
};
416+
417+
export const getNextSiblingOfType = <T extends Element>(element: Element): T | null => {
418+
let sibling = element.nextSibling;
419+
while (sibling) {
420+
if (sibling.nodeType === Node.ELEMENT_NODE && (sibling as T) !== null) {
421+
return sibling as T;
422+
}
423+
sibling = sibling.nextSibling;
424+
}
425+
return null;
426+
};

0 commit comments

Comments
 (0)