Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oojs-router

Package Overview
Dependencies
Maintainers
25
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oojs-router - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

24

dist/oojs-router.js
/*!
* OOjs Router v0.4.0
* OOjs Router v0.5.0
* https://www.mediawiki.org/wiki/OOjs_Router

@@ -9,3 +9,3 @@ *

*
* Date: 2024-03-01T14:46:25Z
* Date: 2024-03-04T20:48:16Z
*/

@@ -23,6 +23,6 @@ ( function ( $ ) {

OO.Router = function OoRouter() {
var router = this;
const router = this;
// Parent constructor
OO.Router.parent.call( this );
OO.Router.super.call( this );

@@ -42,3 +42,3 @@ this.enabled = true;

// event.originalEvent.newURL is undefined on Android 2.x
var routeEvent;
let routeEvent;

@@ -103,5 +103,6 @@ if ( router.enabled ) {

OO.Router.prototype.checkRoute = function () {
var id, entry, match,
hash = this.getPath();
const hash = this.getPath();
let id, entry, match;
for ( id in this.registry ) {

@@ -132,4 +133,5 @@ entry = this.registry[ id ];

OO.Router.prototype.addRoute = function ( path, callback ) {
var entry = {
const entry = {
path: typeof path === 'string' ?
// eslint-disable-next-line security/detect-non-literal-regexp
new RegExp( '^' + path.replace( /[\\^$*+?.()|[\]{}]/g, '\\$&' ) + '$' ) :

@@ -191,7 +193,7 @@ path,

OO.Router.prototype.back = function () {
var timeoutID,
router = this,
const router = this,
deferred = $.Deferred();
this.once( 'popstate', function () {
// eslint-disable-next-line no-use-before-define
clearTimeout( timeoutID );

@@ -209,3 +211,3 @@ deferred.resolve();

// Give browser a few ms to update its history.
timeoutID = setTimeout( function () {
const timeoutID = setTimeout( function () {
router.off( 'popstate' );

@@ -212,0 +214,0 @@ deferred.resolve();

@@ -1,3 +0,3 @@

/*! OOjs Router v0.4.0 | http://oojs.mit-license.org */
!function(i){"use strict";OO.Router=function(){var e=this;OO.Router.parent.call(this),this.enabled=!0,this.oldHash=this.getPath(),window.addEventListener("popstate",function(){e.emit("popstate")}),window.addEventListener("hashchange",function(){e.emit("hashchange")}),this.on("hashchange",function(){var t;e.enabled?(t=i.Event("route",{path:e.getPath()}),e.emit("route",t),t.isDefaultPrevented()?(e.enabled=!1,e.navigate(e.oldHash)):e.checkRoute()):e.enabled=!0,e.oldHash=e.getPath()})},OO.inheritClass(OO.Router,OO.Registry),OO.Router.static.isSupported=function(){return"onhashchange"in window},OO.Router.prototype.checkRoute=function(){var t,e,o,i=this.getPath();for(t in this.registry)if(e=this.registry[t],o=i.match(e.path))return void e.callback.apply(this,o.slice(1))},OO.Router.prototype.addRoute=function(t,e){t={path:"string"==typeof t?new RegExp("^"+t.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")+"$"):t,callback:e};this.register(t.path.toString(),t)},OO.Router.prototype.route=OO.Router.prototype.addRoute,OO.Router.prototype.navigateTo=function(t,e){e.useReplaceState?history.replaceState(null,t,e.path):history.pushState(null,t,e.path)},OO.Router.prototype.navigate=function(t){""===t?(t=window.location.href.replace(/#.*$/,""),history.pushState(null,document.title,t),this.checkRoute()):window.location.hash=t},OO.Router.prototype.back=function(){var t,e=this,o=i.Deferred();return this.once("popstate",function(){clearTimeout(t),o.resolve()}),window.history.back(),t=setTimeout(function(){e.off("popstate"),o.resolve()},50),o.promise()},OO.Router.prototype.getPath=function(){return window.location.hash.slice(1)},OO.Router.prototype.isSupported=OO.Router.static.isSupported,"undefined"!=typeof module&&module.exports&&(module.exports=OO.Router)}(jQuery);
/*! OOjs Router v0.5.0 | http://oojs.mit-license.org */
!function(i){"use strict";OO.Router=function(){const e=this;OO.Router.super.call(this),this.enabled=!0,this.oldHash=this.getPath(),window.addEventListener("popstate",function(){e.emit("popstate")}),window.addEventListener("hashchange",function(){e.emit("hashchange")}),this.on("hashchange",function(){var t;e.enabled?(t=i.Event("route",{path:e.getPath()}),e.emit("route",t),t.isDefaultPrevented()?(e.enabled=!1,e.navigate(e.oldHash)):e.checkRoute()):e.enabled=!0,e.oldHash=e.getPath()})},OO.inheritClass(OO.Router,OO.Registry),OO.Router.static.isSupported=function(){return"onhashchange"in window},OO.Router.prototype.checkRoute=function(){var t=this.getPath();let e,o,i;for(e in this.registry)if(o=this.registry[e],i=t.match(o.path))return void o.callback.apply(this,i.slice(1))},OO.Router.prototype.addRoute=function(t,e){t={path:"string"==typeof t?new RegExp("^"+t.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")+"$"):t,callback:e};this.register(t.path.toString(),t)},OO.Router.prototype.route=OO.Router.prototype.addRoute,OO.Router.prototype.navigateTo=function(t,e){e.useReplaceState?history.replaceState(null,t,e.path):history.pushState(null,t,e.path)},OO.Router.prototype.navigate=function(t){""===t?(t=window.location.href.replace(/#.*$/,""),history.pushState(null,document.title,t),this.checkRoute()):window.location.hash=t},OO.Router.prototype.back=function(){const t=this,e=i.Deferred(),o=(this.once("popstate",function(){clearTimeout(o),e.resolve()}),window.history.back(),setTimeout(function(){t.off("popstate"),e.resolve()},50));return e.promise()},OO.Router.prototype.getPath=function(){return window.location.hash.slice(1)},OO.Router.prototype.isSupported=OO.Router.static.isSupported,"undefined"!=typeof module&&module.exports&&(module.exports=OO.Router)}(jQuery);
//# sourceMappingURL=oojs-router.min.js.map
# OOjs Router Release History
## v0.5.0 / 2024/03/04
* [BREAKING CHANGE] Require oojs 7.0.1, up from 6.0.0 (James D. Forrester)
* [BREAKING CHANGE] Re-write to require ES6, up from ES5 (James D. Forrester)
* [BREAKING CHANGE] Raise jQuery requirement from v3.6.0 to v3.7.1 (James D. Forrester)
* Clean up parent->super (Ed Sanders)
## v0.4.0 / 2023-08-30
* Use native event handling (Jon Robson)
## v0.3.0 / 2021-09-09

@@ -4,0 +13,0 @@ * [BREAKING CHANGE] Require OOjs v6.0.0, up from v2.0.0 (James D. Forrester)

{
"name": "oojs-router",
"version": "0.4.0",
"version": "0.5.0",
"description": "Object-oriented navigation routing library built on top of OOjs.",

@@ -27,21 +27,21 @@ "keywords": [

"dependencies": {
"jquery": "3.6.0",
"oojs": "6.0.0"
"jquery": "3.7.1",
"oojs": "7.0.1"
},
"devDependencies": {
"eslint-config-wikimedia": "0.24.0",
"eslint-config-wikimedia": "0.26.0",
"grunt": "1.6.1",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-concat": "2.0.0",
"grunt-contrib-uglify": "5.0.1",
"grunt-eslint": "24.0.0",
"grunt-contrib-clean": "2.0.1",
"grunt-contrib-concat": "2.1.0",
"grunt-contrib-uglify": "5.2.2",
"grunt-eslint": "24.3.0",
"grunt-karma": "4.0.2",
"karma": "6.3.18",
"karma-chrome-launcher": "3.1.0",
"karma-coverage": "2.0.3",
"karma": "6.4.2",
"karma-chrome-launcher": "3.2.0",
"karma-coverage": "2.2.1",
"karma-firefox-launcher": "2.1.2",
"karma-qunit": "4.1.2",
"qunit": "2.19.4",
"sinon": "12.0.1"
"qunit": "2.20.0",
"sinon": "15.2.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc