Repository navigation
Keep only comments a reader needs in pace.js - #581
Open
CodeByZach wants to merge 1 commit into
Open
CodeByZach wants to merge 1 commit into
CodeByZach wants to merge 1 commit into
Conversation
Comments now say what code does where it isn't obvious, what would
break if it changed, and their sources. The reasons behind choices move
here, where they belong:
- Pace keeps the first copy's object under Symbol.for('pace-js') because
page markup can't replace a symbol property (element names are
strings); a later copy would otherwise wrap requests and history again
and add a second bar.
- RegExps in settings are copied because a RegExp's lastIndex changes as
it's used and the page could freeze it.
- reportError keeps an error's details for window.onerror even when
pace.js is served from another origin.
- A request sent just before a run starts belongs to that run: Turbolinks
sends one, then calls pushState.
- maxWait exists so a request that never ends can't hold the bar forever.
- WebSocket is replaced by a subclass so instanceof, its constants,
subclasses and other libraries' prototype patches keep working.
- waitFor checks every 100 ms because no event says when a selector
starts to match, and a MutationObserver misses matches that come from
state, such as :checked or :defined.
- The document monitor uses addEventListener, not
document.onreadystatechange, so a page that sets that property doesn't
disconnect pace.
- Errors from extra sources are reported only once the run is set up,
because an error listener may call Pace.start().
- The fetch wrapper's checks never throw because fetch itself rejects
input it can't use, such as a URL whose toString() throws.
- es-abstract's IsConstructor uses the same Reflect.construct check;
the comment now credits it.
Only comments change: pace.min.js builds byte-for-byte the same.
This branch has not been deployed
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.
Comments in
pace.jsnow say what code does where it isn't obvious, what would break if it changed, and their sources. The reasons behind earlier choices move into the commit message.Only comments change:
pace.min.jsbuilds byte-for-byte the same.