Skip to content

Conversation

i-am-chitti
Copy link
Member

This PR fixes undefined function type error in TP slider -
image

Background

When working with Web Components/Custom Elements, there's an asynchronous upgrade process that can cause race conditions. Elements queried via querySelector immediately after DOM insertion may not have their custom methods available yet, resulting in TypeError: undefined is not a function errors.

Root Cause: Per the HTML specification, custom element upgrades occur asynchronously. When elements are created (either on initial page load or via innerHTML/AJAX injection), there's a brief window where:

  1. The element exists in the DOM as a plain HTMLElement
  2. querySelector successfully returns the element
  3. Custom element constructors haven't executed yet
  4. Custom methods/properties are undefined

Replication - https://codeshare.io/2j6nYA

This is what causing issue in tp-slider component -

sliderNav?.updateNavItems();

Slack discussion - https://travelopia-it.slack.com/archives/C089GHT0ETV/p1759816852454069?thread_ts=1759816472.395389&cid=C089GHT0ETV

@i-am-chitti i-am-chitti self-assigned this Oct 7, 2025
@i-am-chitti i-am-chitti merged commit 6485991 into master Oct 13, 2025
1 check passed
@i-am-chitti i-am-chitti deleted the fix/QE-1993-slider-js-error branch October 13, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants