perf: drop unused code paths (event.details alias, KeyborgProps, IE9 probe)#174
Closed
layershifter wants to merge 3 commits into
Closed
perf: drop unused code paths (event.details alias, KeyborgProps, IE9 probe)#174layershifter wants to merge 3 commits into
layershifter wants to merge 3 commits into
Conversation
`event.details` was kept as an `@deprecated` alias of `event.detail` for Tabster and other early consumers. The known consumer chain (Tabster's src/State/FocusedElement.ts and elsewhere) reads `e.detail` exclusively, and the field has been marked deprecated for multiple releases. Dropping the field plus the per-dispatch assignment trims a few bytes from every focus-in event handler call site. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
KeyborgProps was the only argument to `createKeyborg`/`createKeyborgCore`, gating two features: * `triggerKeys` — a custom set of keys that should opt the window into keyboard-navigation mode in place of "any non-Tab key on a non-editable element". Never used by any known consumer; the default predicate is already the right behaviour for screen-reader and Tab-driven flows. * `dismissKeys` — a key set that scheduled a 500 ms timer to dismiss keyboard mode if focus did not move (typically wired to Escape). This hand-rolled latch duplicated work consumers already do at the application level. Drop the props interface, the `shouldDismiss`/`scheduleDismiss`/ `dismissTimer`/`_dismissTimeout` machinery, and the `triggerKeys` membership check in `shouldTrigger`. `onKeyDown` collapses to a single guard: enter keyboard mode if not already in it and the key should trigger. `KeyborgProps` was never re-exported from `src/index.mts`, so the public surface stays compatible aside from the (still-typed) extra `createKeyborg` parameter going away. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `canOverrideNativeFocus` helper detected whether reassigning `HTMLElement.prototype.focus` was respected by the browser. The check was guarding against pre-IE9 behaviour where prototype overrides were ignored. Every browser keyborg currently supports honours the override, so the `_canOverrideNativeFocus` flag is effectively always true after the first call. Replace the conditional `details.isFocusedProgrammatically` write with an unconditional one — semantically identical when the override works, which is the only case we still ship for — and drop the probe entirely. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📊 Bundle size reportUnchanged fixtures
|
Member
Author
|
Splitting into three focused PRs, one per trim, for independent review. |
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
Three independent trims that remove code paths none of keyborg's known consumers exercise. Upstreams the changes microsoft/tabster#539 currently applies via
patch-packageagainstkeyborg@2.14.0's installed bundle.The commit is split into three commits for clean review and bisection:
event.detailsalias onKeyborgFocusInEvent— the@deprecatedalias ofevent.detail. Tabster readse.detailexclusively (verified acrosssrc/State/FocusedElement.tsand the rest of the codebase). Drops the field on the interface plus the per-dispatchevent.details = detailsassignment insetupFocusEvent.KeyborgProps(triggerKeys/dismissKeys) + dismiss timer machinery —KeyborgPropswas never re-exported fromsrc/index.mtsand no known consumer passes props tocreateKeyborg. Removes the interface, thetriggerKeys/dismissKeysSets,shouldDismiss/scheduleDismiss/dismissTimer/_dismissTimeout, and collapsesonKeyDownto a single trigger guard.canOverrideNativeFocusruntime probe +_canOverrideNativeFocusflag — the probe detected pre-IE9 environments where reassigningHTMLElement.prototype.focuswas ignored. Every browser keyborg currently supports honours the override, so the gateddetails.isFocusedProgrammaticallywrite becomes unconditional. Semantically identical when the override works, which is the only case we still ship for.Public API impact
KeyborgFocusInEventinterface no longer carriesdetails?: KeyborgFocusInEventDetails. The field has been marked@deprecatedfor several releases; consumers should useevent.detail.createKeyborg(win, props?)→createKeyborg(win).KeyborgPropstype is removed. Not previously re-exported, so the only breakage is callers passing the second argument (the type narrowing already silently ignored unknown shapes — passingundefinedcontinues to work since the parameter is gone entirely).__keyborg.coreor__keyborg.refs.Worth treating as a minor or major bump depending on how the maintainers want to handle the dropped
detailsfield.Bundle deltas (monosize)
Matches microsoft/tabster#539's measurement of
−590 Bon keyborg's slice of the Tabster bundle within ~20 B of slack.Tests
Existing Playwright suite (14 tests covering focus behavior, focus-in events, shadow DOM nesting, and cross-version interop) passes unchanged.
Test plan
yarn build(CJS + ESM, types)yarn lintyarn formatyarn test(14/14)yarn bundle-size🤖 Generated with Claude Code