Repository navigation
Conversation
The first-page pageAdded fix overrode addListener, prependListener and prependOnceListener on every build. The browser build's event base has on() and once() only, so code that checks typeof addListener and then calls it threw, where master fell back to on(). These overrides are now added only for the listener methods the base class really has. The browser build gets on() and once() overrides only, so feature detection falls back to on() as it does on master. Agent: claude
Member
|
Not a clean solution. Better either an on parameter in constructor that attaches events or a onPageAdded constructor param. Elaborate tradeoffs and propose a new PR |
4 tasks
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.
What kind of change does this PR introduce?
Bug fix. Fixes #1529.
With default
autoFirstPage, the constructor adds page 1 before listeners attach, sopageAddedis missed:The constructor now suppresses and holds that
pageAddedevent, delivering it synchronously (page 1 current) to the first listener attached viaon,once,addListener,prependListener, orprependOnceListener. On the browser build,addListener,prependListener, andprependOnceListenerare overridden only if defined on the base stream, preserving feature-detection fallback toon(). IfaddPage()orend()runs first, the held event is dropped. With no listener orautoFirstPage: false, behavior is unchanged.Behavior change: a
pageAddedlistener attached before another page now runs once synchronously insideon()(or other attach methods). Callers assuming it waits for the nextaddPage()see one extra call.Tests: 7 unit tests added in
tests/unit/document.spec.js. Ran on a box:yarn install --immutable && yarn vitest run tests/unit(616 of 616 passed in 47 files; exit 0),yarn install --immutable && yarn vitest run tests/unit/document.spec.js(22 of 22 passed; exit 0; withlib/document.jsreverted to master, 5 of the 7 new tests fail; exit 1),yarn lint(exit 0),yarn prettier --check lib tests(exit 0), andyarn build(exit 0).Checklist:
Written with AI assistance.