Repository navigation
Skip missing windows without errors and drop the saAutomatedLink global - #142
Merged
Merged
Conversation
auto-events.js referenced window at the call site, so it threw outside a browser. Both scripts now pass `typeof window < "u" && window`, which is also shorter than the previous check in latest.js. saAutomatedLink was only global for the onclick attributes that v12 replaced with click listeners, so it is now a local function. The tests click real links instead of calling the global. Fixes #141 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Claude review checkpointReviewed commit |
Contributor
|
SDLC label: |
adriaandotcom
approved these changes
Oct 22, 2026
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.
Summary
Fixes #141
typeof window < "u" && windowto their wrapper and return early when it isfalse. Before this,auto-events.jspassed a barewindowand threwReferenceError: window is not definedoutside a browser. Its owntypeof window === "undefined"check never ran, because the call site threw first.typeofreturns"undefined"(which sorts after"u") only when there is no window, so this replaces the longer"undefined" != typeof windowcheck inlatest.js.window.saAutomatedLink. It was global only because of theonclick="saAutomatedLink(this, '…')"attributes, which v12 replaced with click listeners. It is now a local function declaration. It wasn't documented, and the only other user was the retiredcloudflare-apprepository.Size compared with
main(same build, gzip -9, brotli 11):latest.jslight.jsauto-events.jsI also tried skipping the whole wrapper with
typeof window < "u" && (function (…) {…})(window, …). That saves 37 B minified / 7 B gzip onlatest.js, but Prettier then reindents all 1,194 lines ofsrc/default.js, so I left it out.dist/is not included.Security implications
Testing
pnpm run test:unit: 72 passing.test/unit/no-window.test.jsevaluateslatest.js,light.jsandauto-events.jsin a context withoutwindow. Onmain,auto-events.jsthrowsReferenceError: window is not defined. With this change, none of them throw.window.saAutomatedLink. The namespaced tracker tests (ba_event,my_event) bind a real link in jsdom, click it, and check thatwindow.saAutomatedLinkisundefined. They fail onmain.pnpm run test:deploy: 20 passing.pnpm run typecheckpasses.src/default.jsalready exist onmain.Open workspace in Conductor
Summary by CodeRabbit
windowobject is unavailable.