@@ -2,7 +2,7 @@ import type { ComponentInterface } from '@stencil/core';
22import { Component , Element , Host , Prop , Method , State , Watch , forceUpdate , h } from '@stencil/core' ;
33import type { ButtonInterface } from '@utils/element-interface' ;
44import type { Attributes } from '@utils/helpers' ;
5- import { addEventListener , removeEventListener , inheritAttributes } from '@utils/helpers' ;
5+ import { addEventListener , removeEventListener , inheritAttributes , getNextSiblingOfType } from '@utils/helpers' ;
66import { hostContext } from '@utils/theme' ;
77
88import { 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 ;
0 commit comments