Repository navigation
fix: give each picker its own options - #79
Merged
Merged
Conversation
Two pickers on one page: a picker created without options must get the defaults, a later picker with other options must leave the earlier one unchanged, and the two must not share an options object. Fails on 5.0.0 because the constructor writes into the shared DEFAULT_OPTIONS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The constructor ran Object.assign(DEFAULT_OPTIONS, opts), which wrote every caller's options into the module-level defaults and returned that shared object. A picker created without options inherited an earlier picker's theme and language, and creating a picker changed every earlier picker's options. Spread the defaults and the caller's options into a new object per instance instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonataswalker
force-pushed
the
fix/per-instance-options
branch
from
November 16, 2026 19:49
ae1f91c to
8791cb4
Compare
jonataswalker
marked this pull request as ready for review
November 16, 2026 19:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Implements spec #543: each
TimePickergets its own options object. Patch release (expected 5.0.1).Bug
src/main.tsranconst options = Object.assign(DEFAULT_OPTIONS, opts). That writes the caller's options into the module-levelDEFAULT_OPTIONSand returns that same object, so:new TimePicker(a, { theme: 'red', lang: 'pt' }), a laternew TimePicker(b)is red with Portuguese labelsoptionsEvery release with that line is affected, including 5.0.0.
Fix
Optionsholds only two strings (lang,theme), so a shallow copy is enough.DEFAULT_OPTIONSis no longer written anywhere.Regression test first
tests/options-isolation.spec.ts, 2 tests × 3 projects (Chromium, Firefox, Mobile Chrome). Each creates two pickers on the test page:{ theme: 'red', lang: 'pt' }. Second picker gets{ theme: 'dark', lang: 'en' },Hour/Minutelabels, and only classes the page's default picker also has (that picker is created at load, before any test code). Its classes differ from the first picker's. The page's default picker still readsdark/en.red/ptkeeps its options andHora/Minutolabels after a secondblue/depicker (Stunde/Minute). Their classes differ, and the two don't share an options object.The commits are in order:
8791cb4adds the test alone. CI run 43943327063 failed on Node 22, 24 and 26 with exactly these 6 runs failing, for example: expected{ lang: 'en', theme: 'dark' }, received{ lang: 'pt', theme: 'red' }. The other 39 passed on each line.f3d4069is the fix.The test commit was made with
HUSKY=0, because the pre-commit hook runsnpm test, and a deliberately failing test can't pass it. Lint, typecheck and format were run by hand for that commit.Gate
npm run verifyexits 0 locally (Node 26.13.1, npm 12.2.2):versionis untouched.🤖 Generated with Claude Code