Repository navigation
fix(185000): never throw on invalid stored tour/tooltip selectors - #172
Merged
Merged
Conversation
A selector typed without brackets (data-x="y") made querySelector throw in the tour highlight; the colon-escape fallback in the catch threw again, so the tour died in its retry timer instead of ending via onElementNotFound. Copilot tours polled forever, tooltip matching threw on every DOM mutation and the builder's highlight/click messages threw too. GleapSafeSelector tries the stored selector, then the bracketed attribute form, then the colon-escaped id form, and resolves to nothing otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gleap ticket #185000.
Problem
A tour step selector typed without brackets (
data-x="y"instead of[data-x="y"]) makesdocument.querySelectorthrow. InGleapTours.highlightthe catch retried with the colon-escaped form, which threw again inside the retry timer, so the tour died with an uncaught error instead of ending throughonElementNotFound. Same class of bug elsewhere:waitForElement: the throw insidesetIntervalrepeated every 100 ms forever and the promise never settled.node.matches(selector)in the MutationObserver threw on every DOM mutation.highlight-element/clickmessages.Fix
New
GleapSafeSelector(querySelectorSafe,querySelectorAllSafe,matchesSelectorSafe): tries the stored selector, then the bracketed attribute form, then the colon-escaped id form; anything still invalid resolves to nothing (oneconsole.warnper selector). Used in tours, copilot tours, tooltips and the admin bridge. Existing tours with a bare attribute selector now find their element.Companion editor validation: GleapSDK/Frontend (same branch name).
Verified
npm test: 521/521 pass;npm run buildsucceeds (build/published artifacts left to the release).#a:bstill resolves,div[[[→ null; a tour withdiv[[[ends viaonElementNotFoundwithout throwing; a tour withdata-pf="…"highlights the element.🤖 Generated with Claude Code