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

single-spa

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

single-spa - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

59

lib/jquery-support.js

@@ -7,2 +7,5 @@ 'use strict';

exports.ensureJQuerySupport = ensureJQuerySupport;
var _singleSpa = require('./single-spa.js');
var hasInitialized = false;

@@ -24,39 +27,7 @@

jQuery.fn.on = function (eventString, fn) {
if (typeof eventString !== 'string') {
return originalJQueryOn.apply(this, arguments);
}
var eventNames = eventString.split(/\s+/);
eventNames.forEach(function (eventName) {
if (eventName === 'hashchange' || eventName === 'popstate') {
window.addEventListener(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryOn.apply(this, arguments);
}
return captureRoutingEvents.call(this, originalJQueryOn, window.addEventListener, eventString, fn, arguments);
};
jQuery.fn.off = function (eventString, fn) {
if (typeof eventString !== 'string') {
return originalJQueryOn.apply(this, arguments);
}
var eventNames = eventString.split(/\s+/);
eventNames.forEach(function (eventName) {
if (eventName === 'hashchange' || eventName === 'popstate') {
window.removeEventListener(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryOff.apply(this, arguments);
}
return captureRoutingEvents.call(this, originalJQueryOff, window.removeEventListener, eventString, fn, arguments);
};

@@ -67,2 +38,22 @@

}
}
function captureRoutingEvents(originalJQueryFunction, nativeFunctionToCall, eventString, fn, originalArgs) {
if (typeof eventString !== 'string') {
return originalJQueryFunction.apply(this, originalArgs);
}
var eventNames = eventString.split(/\s+/);
eventNames.forEach(function (eventName) {
if (_singleSpa.routingEventsListeningTo.indexOf(eventName) >= 0) {
nativeFunctionToCall(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryFunction.apply(this, originalArgs);
}
}

@@ -6,2 +6,3 @@ 'use strict';

});
exports.routingEventsListeningTo = undefined;

@@ -40,2 +41,5 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

// Constants that don't change no matter what
var routingEventsListeningTo = exports.routingEventsListeningTo = ['hashchange', 'popstate'];
// Things that need to be reset with the init function;

@@ -74,12 +78,6 @@ var Loader = void 0,

if (typeof fn === 'function') {
if (eventName === 'hashchange' && !capturedEventListeners.hashchange.find(function (listener) {
if (routingEventsListeningTo.indexOf(eventName) >= 0 && !capturedEventListeners[eventName].find(function (listener) {
return listener === fn;
})) {
capturedEventListeners.hashchange.push(fn);
return;
} else if (eventName === 'popstate' && !capturedEventListeners.popstate.find(function (listener) {
return listener === fn;
})) {
capturedEventListeners.popstate.push(fn);
return;
capturedEventListeners[eventName].push(fn);
}

@@ -93,12 +91,6 @@ }

if (typeof listenerFn === 'function') {
if (eventName === 'hashchange') {
capturedEventListeners.hashchange = capturedEventListeners.hashchange.filter(function (fn) {
if (routingEventsListeningTo.indexOf(eventName) >= 0) {
capturedEventListeners[eventName] = capturedEventListeners[eventName].filter(function (fn) {
return fn.toString() !== listenerFn.toString();
});
return;
} else if (eventName === 'popstate') {
capturedEventListeners.popstate = capturedEventListeners.popstate.filter(function (fn) {
return fn.toString() !== listenerFn.toString();
});
return;
}

@@ -282,10 +274,7 @@ }

if (eventArguments) {
if (eventArguments[0].type === 'hashchange') {
capturedEventListeners.hashchange.forEach(function (listener) {
var eventType = eventArguments[0].type;
if (routingEventsListeningTo.indexOf(eventType) >= 0) {
capturedEventListeners[eventType].forEach(function (listener) {
listener.apply(_this, eventArguments);
});
} else if (eventArguments[0].type === 'popstate') {
capturedEventListeners.popstate.forEach(function (listener) {
listener.apply(_this, eventArguments);
});
}

@@ -292,0 +281,0 @@ }

{
"name": "single-spa",
"version": "2.0.3",
"version": "2.0.4",
"description": "Multiple applications, one page",

@@ -5,0 +5,0 @@ "main": "lib/single-spa.js",

# single-spa
[![npm version](https://img.shields.io/npm/v/single-spa.svg?style=flat-square)](https://www.npmjs.org/package/single-spa)
[![Build Status](https://img.shields.io/travis/CanopyTax/single-spa.svg?style=flat-square)](https://travis-ci.org/CanopyTax/single-spa)

@@ -3,0 +5,0 @@ Multiple applications all lazily loaded and mounted/unmounted in the same single page application (SPA). The apps can be deployed independently to your web server of choice, lazy-loaded onto the page independently, and nested. Single-spa also allows for **service oriented javascript**, where a "service" (a shared es6 module) is a singleton that each app can call, without resorting to shared libraries that can be out of sync across apps.

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

import { routingEventsListeningTo } from './single-spa.js';
let hasInitialized = false;

@@ -16,43 +18,31 @@

jQuery.fn.on = function(eventString, fn) {
if (typeof eventString !== 'string') {
return originalJQueryOn.apply(this, arguments);
}
const eventNames = eventString.split(/\s+/);
eventNames.forEach(eventName => {
if (eventName === 'hashchange' || eventName === 'popstate') {
window.addEventListener(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryOn.apply(this, arguments);
}
return captureRoutingEvents.call(this, originalJQueryOn, window.addEventListener, eventString, fn, arguments);
}
jQuery.fn.off = function(eventString, fn) {
if (typeof eventString !== 'string') {
return originalJQueryOn.apply(this, arguments);
}
return captureRoutingEvents.call(this, originalJQueryOff, window.removeEventListener, eventString, fn, arguments);
}
const eventNames = eventString.split(/\s+/);
eventNames.forEach(eventName => {
if (eventName === 'hashchange' || eventName === 'popstate') {
window.removeEventListener(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
hasInitialized = true;
}
}
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryOff.apply(this, arguments);
}
function captureRoutingEvents(originalJQueryFunction, nativeFunctionToCall, eventString, fn, originalArgs) {
if (typeof eventString !== 'string') {
return originalJQueryFunction.apply(this, originalArgs);
}
const eventNames = eventString.split(/\s+/);
eventNames.forEach(eventName => {
if (routingEventsListeningTo.indexOf(eventName) >= 0) {
nativeFunctionToCall(eventName, fn);
eventString = eventString.replace(eventName, '');
}
});
hasInitialized = true;
if (eventString.trim() === '') {
return this;
} else {
return originalJQueryFunction.apply(this, originalArgs);
}
}

@@ -17,2 +17,5 @@ import { handleChildAppError } from './single-spa-child-app-error.js';

// Constants that don't change no matter what
export const routingEventsListeningTo = ['hashchange', 'popstate'];
// Things that need to be reset with the init function;

@@ -44,8 +47,4 @@ let Loader, childApps, bootstrapMaxTime, mountMaxTime, unmountMaxTime, peopleWaitingOnAppChange, appChangeUnderway, capturedEventListeners;

if (typeof fn === 'function') {
if (eventName === 'hashchange' && !capturedEventListeners.hashchange.find(listener => listener === fn)) {
capturedEventListeners.hashchange.push(fn);
return;
} else if (eventName === 'popstate' && !capturedEventListeners.popstate.find(listener => listener === fn)) {
capturedEventListeners.popstate.push(fn);
return;
if (routingEventsListeningTo.indexOf(eventName) >= 0 && !capturedEventListeners[eventName].find(listener => listener === fn)) {
capturedEventListeners[eventName].push(fn);
}

@@ -59,8 +58,4 @@ }

if (typeof listenerFn === 'function') {
if (eventName === 'hashchange') {
capturedEventListeners.hashchange = capturedEventListeners.hashchange.filter(fn => fn.toString() !== listenerFn.toString());
return;
} else if (eventName === 'popstate') {
capturedEventListeners.popstate = capturedEventListeners.popstate.filter(fn => fn.toString() !== listenerFn.toString());
return;
if (routingEventsListeningTo.indexOf(eventName) >= 0) {
capturedEventListeners[eventName] = capturedEventListeners[eventName].filter(fn => fn.toString() !== listenerFn.toString());
}

@@ -259,10 +254,7 @@ }

if (eventArguments) {
if (eventArguments[0].type === 'hashchange') {
capturedEventListeners.hashchange.forEach(listener => {
const eventType = eventArguments[0].type;
if (routingEventsListeningTo.indexOf(eventType) >= 0) {
capturedEventListeners[eventType].forEach(listener => {
listener.apply(this, eventArguments);
});
} else if (eventArguments[0].type === 'popstate') {
capturedEventListeners.popstate.forEach(listener => {
listener.apply(this, eventArguments);
});
}

@@ -269,0 +261,0 @@ }

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