()
| 177 | } |
| 178 | |
| 179 | async connectedCallback() { |
| 180 | const { didLoad, el } = this; |
| 181 | |
| 182 | /** |
| 183 | * If we have not yet rendered |
| 184 | * ion-toggle, then toggleTrack is not defined. |
| 185 | * But if we are moving ion-toggle via appendChild, |
| 186 | * then toggleTrack will be defined. |
| 187 | */ |
| 188 | if (didLoad) { |
| 189 | this.setupGesture(); |
| 190 | } |
| 191 | |
| 192 | // Watch for class changes to update validation state. |
| 193 | if (Build.isBrowser && typeof MutationObserver !== 'undefined') { |
| 194 | this.validationObserver = new MutationObserver(() => { |
| 195 | const newIsInvalid = checkInvalidState(el); |
| 196 | if (this.isInvalid !== newIsInvalid) { |
| 197 | this.isInvalid = newIsInvalid; |
| 198 | /** |
| 199 | * Screen readers tend to announce changes |
| 200 | * to `aria-describedby` when the attribute |
| 201 | * is changed during a blur event for a |
| 202 | * native form control. |
| 203 | * However, the announcement can be spotty |
| 204 | * when using a non-native form control |
| 205 | * and `forceUpdate()`. |
| 206 | * This is due to `forceUpdate()` internally |
| 207 | * rescheduling the DOM update to a lower |
| 208 | * priority queue regardless if it's called |
| 209 | * inside a Promise or not, thus causing |
| 210 | * the screen reader to potentially miss the |
| 211 | * change. |
| 212 | * By using a State variable inside a Promise, |
| 213 | * it guarantees a re-render immediately at |
| 214 | * a higher priority. |
| 215 | */ |
| 216 | Promise.resolve().then(() => { |
| 217 | this.hintTextId = this.getHintTextId(); |
| 218 | }); |
| 219 | } |
| 220 | }); |
| 221 | |
| 222 | this.validationObserver.observe(el, { |
| 223 | attributes: true, |
| 224 | attributeFilter: ['class'], |
| 225 | }); |
| 226 | } |
| 227 | |
| 228 | // Always set initial state |
| 229 | this.isInvalid = checkInvalidState(el); |
| 230 | } |
| 231 | |
| 232 | componentDidLoad() { |
| 233 | this.setupGesture(); |
nothing calls this directly
no test coverage detected