From c5c087bacd1f3f9937f97558bcbd86de9487879c Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 6 Feb 2019 12:22:03 -0800 Subject: [PATCH] resources: Update OOjs-Router from v0.1.0 to v0.2.0 Change-Id: Ib6847f7328f28f31141f3ae59f0f9a0f49dbf508 --- RELEASE-NOTES-1.33 | 1 + maintenance/resources/foreign-resources.yaml | 6 +++-- resources/lib/oojs-router/AUTHORS.txt | 6 +++++ resources/lib/oojs-router/History.md | 23 ++++++++++++++++++ resources/lib/oojs-router/oojs-router.js | 25 ++++++++++++++++---- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 resources/lib/oojs-router/History.md diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 0ce23808e4..027aacd776 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -53,6 +53,7 @@ production. ==== Changed external libraries ==== * Updated OOUI from v0.29.2 to v0.30.2. +* Updated OOjs Router from pre-release to v0.2.0. * Updated wikimedia/xmp-reader from 0.6.0 to 0.6.1. * Updated wikimedia/scoped-callback from 2.0.0 to 3.0.0. * Updated wikimedia/ip-set from 1.2.0 to 2.0.0. diff --git a/maintenance/resources/foreign-resources.yaml b/maintenance/resources/foreign-resources.yaml index cf8ed78b24..ee74bb3988 100644 --- a/maintenance/resources/foreign-resources.yaml +++ b/maintenance/resources/foreign-resources.yaml @@ -112,11 +112,13 @@ oojs: oojs-router: type: tar - src: https://registry.npmjs.org/oojs-router/-/oojs-router-0.1.0.tgz - integrity: sha384-h5D3oeG4TeizHhgXY8Z9ghnas3BcNQI7keiUrwS06Zu4zSCiU6ht+Tu8eRbWuqhs + src: https://registry.npmjs.org/oojs-router/-/oojs-router-0.2.0.tgz + integrity: sha384-VngYqdQ3vTDMXbm4e4FUZCCGos7fB0Jkr9V+kBL5MElprK1h0yQZOzBNnMHtSJS/ dest: package/dist/oojs-router.js: package/LICENSE: + package/AUTHORS.txt: + package/History.md: ooui: type: tar diff --git a/resources/lib/oojs-router/AUTHORS.txt b/resources/lib/oojs-router/AUTHORS.txt index 5390c84cb2..a406b57ac6 100644 --- a/resources/lib/oojs-router/AUTHORS.txt +++ b/resources/lib/oojs-router/AUTHORS.txt @@ -1 +1,7 @@ +Ed Sanders +James D. Forrester Jon Robson +Kunal Mehta +MarcoAurelio +Prateek Saxena +Timo Tijhof diff --git a/resources/lib/oojs-router/History.md b/resources/lib/oojs-router/History.md new file mode 100644 index 0000000000..c3889cfbe0 --- /dev/null +++ b/resources/lib/oojs-router/History.md @@ -0,0 +1,23 @@ +# OOjs Router Release History +## v0.2.0 / 2019-02-06 +* build: Misc clean up (Timo Tijhof) +* Code style fixes and refactoring (Ed Sanders) +* build: Switch to ESLint (Timo Tijhof) +* Unit tests (Jon Robson) +* Add .gitreview (Christian Aistleitner) +* Remove .arcconfig & .arclint (MarcoAurelio) +* Add jsduck config (Prateek Saxena) +* build: Update devDependencies (Ed Sanders) +* Use standard coverage reporting configuration (Kunal Mehta) +* Update eslint-config-wikimedia to 0.9.0 (Ed Sanders) +* build: Update devDependencies (Ed Sanders) +* build: Structure updates (Timo Tijhof) +* OOjs Router method to provide access to replaceState (Jon Robson) +* build: Switch from prepublish to prepare for modern npm (James D. Forrester) +* build: Bump package-lock.json for npm audit (James D. Forrester) +* build: Add AUTHORS.txt to package manifest (James D. Forrester) +* AUTHORS.txt: Add everyone from `git shortlog` (James D. Forrester) + +## v0.1.0 / 2016-05-05 +* Initial commit (Jon Robson) +* Add build, CI infrastructure (James D. Forrester) diff --git a/resources/lib/oojs-router/oojs-router.js b/resources/lib/oojs-router/oojs-router.js index 03aeeb2040..111d0e8055 100644 --- a/resources/lib/oojs-router/oojs-router.js +++ b/resources/lib/oojs-router/oojs-router.js @@ -1,12 +1,12 @@ /*! - * OOjs Router v0.1.0 + * OOjs Router v0.2.0 * https://www.mediawiki.org/wiki/OOjs_Router * * Copyright 2011-2019 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2019-01-11T03:40:55Z + * Date: 2019-02-06T21:26:01Z */ ( function ( $ ) { @@ -142,15 +142,32 @@ OO.Router.prototype.route = OO.Router.prototype.addRoute; /** * Navigate to a specific route. * + * @param {string} title of new page + * @param {Object} options + * @param {string} options.path e.g. '/path/' or '/path/#foo' + * @param {boolean} options.useReplaceState Set replaceStateState to use pushState when you want to + * avoid long history queues. + */ +OO.Router.prototype.navigateTo = function ( title, options ) { + if ( options.useReplaceState ) { + history.replaceState( null, title, options.path ); + } else { + history.pushState( null, title, options.path ); + } +}; + +/** + * Navigate to a specific ''hash fragment'' route. + * * @param {string} path String with a route (hash without #). + * @deprecated use navigateTo instead */ OO.Router.prototype.navigate = function ( path ) { - var history = window.history; // Take advantage of `pushState` when available, to clear the hash and // not leave `#` in the history. An entry with `#` in the history has // the side-effect of resetting the scroll position when navigating the // history. - if ( path === '' && history && history.pushState ) { + if ( path === '' ) { // To clear the hash we need to cut the hash from the URL. path = window.location.href.replace( /#.*$/, '' ); history.pushState( null, document.title, path ); -- 2.20.1