Repository navigation
Add Pace.version, run only the first copy of pace on a page - #580
Open
CodeByZach wants to merge 1 commit into
Open
CodeByZach wants to merge 1 commit into
CodeByZach wants to merge 1 commit into
Conversation
- Pace.version is the package version. The build stamps it from
package.json into pace.js, as it already does for the header, so CI's
check that the build is up to date also catches a mismatch.
- Pace.running is read-only: an accessor, so assigning to it does
nothing (or throws in strict-mode code) instead of changing what pace
reports.
- Pace.bar, Pace.sources and Pace.bindings are removed: they exposed
pace's internals. The event handlers live in pace's closure.
- A second copy of pace on a page (another script tag or bundle) logs a
warning and does nothing else; a bundled one exports the first copy.
Before, it merged into window.Pace and wrapped XMLHttpRequest, fetch
and history again, so the page showed two bars. The first copy is
found through window[Symbol.for('pace-js')], which page markup can't
replace (element names are strings), or, for Pace 1.x, which doesn't
set it, a window.Pace with a start function. A copy registers itself
only once it's complete. zone.js and Sentry also let the first copy
win; Datadog and Lit warn about a second one.
- Any other window.Pace, such as an element with id="Pace", is replaced.
Before, pace added its functions to it, and a cross-origin frame named
Pace stopped pace at load.
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.
Adds
Pace.version, makesPace.runningread-only, removes internal properties, and runs only the first copy of pace on a page.Pace.version: the package version, stamped intopace.jsby the build frompackage.json.Pace.runningis read-only.Pace.bar,Pace.sourcesandPace.bindings, which exposed pace's internals.window[Symbol.for('pace-js')], which page markup can't replace.window.Pace, such as an element withid="Pace", is replaced. Before, pace added its functions to it, and a cross-origin frame namedPacestopped pace at load.Tests cover each property and each case of a second copy; all 10 fail on the previous code.