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

can-route

Package Overview
Dependencies
Maintainers
9
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-route - npm Package Compare versions

Comparing version 4.0.0-pre.16 to 4.0.0-pre.18

22

can-route.js

@@ -7,7 +7,2 @@ /*jshint -W079 */

var devLog = require('can-log/dev/dev');
var each = require('can-util/js/each/each');
var isFunction = require('can-util/js/is-function/is-function');
var isWebWorker = require('can-util/js/is-web-worker/is-web-worker');
var isBrowserWindow = require('can-util/js/is-browser-window/is-browser-window');
var assign = require("can-util/js/assign/assign");
var canReflect = require('can-reflect');

@@ -25,2 +20,7 @@ var canSymbol = require('can-symbol');

var isWebWorker = require('can-globals/is-web-worker/is-web-worker');
var isBrowserWindow = require('can-globals/is-browser-window/is-browser-window');
bindingProxy.bindings.hashchange = hashchange;

@@ -154,3 +154,3 @@ bindingProxy.defaultBinding = "hashchange";

assign(canRoute, {
canReflect.assignMap(canRoute, {
param: routeParam,

@@ -238,3 +238,3 @@ deparam: routeDeparam,

each(['addEventListener','removeEventListener','bind', 'unbind', 'on', 'off'], function(name) {
['addEventListener','removeEventListener','bind', 'unbind', 'on', 'off'].forEach(function(name) {
// exposing all internal eventQueue evt’s to canRoute

@@ -249,3 +249,3 @@ canRoute[name] = function(eventName, handler) {

each(['delegate', 'undelegate', 'removeAttr', 'compute', '_get', '___get', 'each'], function (name) {
['delegate', 'undelegate', 'removeAttr', 'compute', '_get', '___get', 'each'].forEach(function (name) {
canRoute[name] = function () {

@@ -293,10 +293,10 @@ // `delegate` and `undelegate` require

// Get array from array-like or shallow-copy object
obj = isFunction(obj.slice) ? obj.slice() : assign({}, obj);
obj = typeof obj.slice === "function" ? obj.slice() : canReflect.assign({}, obj);
}
// Convert each object property or array item into stringified new
each(obj, function (val, prop) {
canReflect.eachKey(obj, function (val, prop) {
obj[prop] = stringify(val);
});
// Object supports toString function
} else if (obj !== undefined && obj !== null && isFunction(obj.toString)) {
} else if (obj !== undefined && obj !== null && (typeof obj.toString === "function" )) {
obj = obj.toString();

@@ -303,0 +303,0 @@ }

{
"name": "can-route",
"version": "4.0.0-pre.16",
"version": "4.0.0-pre.18",
"description": "Observable front-end application routing for CanJS.",

@@ -37,3 +37,6 @@ "homepage": "https://canjs.com/doc/can-route.html",

"can-deparam": "^1.0.1",
"can-dom-events": "^1.1.0",
"can-event-queue": "<2.0.0",
"can-globals": "<2.0.0",
"can-key-tree": "<2.0.0",
"can-log": "<2.0.0",

@@ -49,4 +52,3 @@ "can-namespace": "1.0.0",

"can-symbol": "^1.0.0",
"can-util": "^3.9.0",
"can-key-tree": "<2.0.0"
"can-util": "^3.9.0"
},

@@ -53,0 +55,0 @@ "devDependencies": {

@@ -1,6 +0,6 @@

var makeArray = require('can-util/js/make-array/make-array');
var canReflect = require('can-reflect');
var canSymbol = require("can-symbol");
var SimpleObservable = require("can-simple-observable");
var defaultBinding = new SimpleObservable("hashchange")
var defaultBinding = new SimpleObservable("hashchange");

@@ -17,3 +17,3 @@ var bindingProxy = {

call: function(){
var args = makeArray(arguments),
var args = canReflect.toArray(arguments),
prop = args.shift(),

@@ -20,0 +20,0 @@ binding = bindingProxy.bindings[bindingProxy.currentBinding ||bindingProxy.defaultBinding],

var deparam = require('can-deparam');
var canReflect = require("can-reflect");
var deepAssign = require('can-util/js/deep-assign/deep-assign');

@@ -16,9 +15,15 @@ var bindingProxy = require("./binding-proxy");

function canRoute_getRule(url){
// TODO: I'm not totally sure this belongs here. This might be shifted to can-route-pushstate.
function toURLFragment(url){
var root =bindingProxy.call("root");
if (root.lastIndexOf("/") === root.length - 1 &&
url.indexOf("/") === 0) {
// if the root ends with `/` and the url starts with it, remove /
if (root.lastIndexOf("/") === root.length - 1 && url.indexOf("/") === 0) {
url = url.substr(1);
}
return url;
}
function canRoute_getRule(url){
url = toURLFragment(url);
// See if the url matches any routes by testing it against the `route.test` `RegExp`.

@@ -98,3 +103,6 @@ // By comparing the URL length the most specialized route that matches is used.

paramsMatcher =bindingProxy.call("paramsMatcher");
// If a route was matched.
url = toURLFragment(url);
// If a route was matched.
if (route) {

@@ -113,3 +121,3 @@

// Add the default values for this route.
obj = deepAssign(true, {}, route.defaults, obj);
obj = canReflect.assignDeep(canReflect.assignDeep({}, route.defaults), obj);
// Overwrite each of the default values in `obj` with those in

@@ -116,0 +124,0 @@ // parts if that part is not empty.

@@ -6,3 +6,3 @@ // Regular expression for identifying &amp;key=value lists.

var canReflect = require("can-reflect");
var domEvents = require("can-util/dom/events/events");
var ObservationRecorder = require("can-observation-recorder");

@@ -13,2 +13,3 @@ var queues = require("can-queues");

var domEvents = require("can-dom-events");

@@ -26,6 +27,6 @@ function getHash(){

self.value = getHash();
domEvents.addEventListener.call(window, 'hashchange', dispatchHandlers);
domEvents.addEventListener(window, 'hashchange', dispatchHandlers);
},
onEmpty: function(){
domEvents.removeEventListener.call(window, 'hashchange', dispatchHandlers);
domEvents.removeEventListener(window, 'hashchange', dispatchHandlers);
}

@@ -32,0 +33,0 @@ });

@@ -1,5 +0,2 @@

var each = require('can-util/js/each/each');
var assign = require("can-util/js/assign/assign");
var isEmptyObject = require('can-util/js/is-empty-object/is-empty-object');
var canReflect = require("can-reflect");
var param = require('can-param');

@@ -47,3 +44,2 @@

matchCount,
routeName,
propCount = 0;

@@ -53,7 +49,7 @@

each(data, function () {
canReflect.eachKey(data, function () {
propCount++;
});
// Otherwise find route.
each(register.routes, function (temp, name) {
canReflect.eachKey(register.routes, function (temp, name) {
// best route is the first with all defaults matching

@@ -85,3 +81,3 @@

cpy = assign({}, data);
cpy = canReflect.assignMap({}, data);
// fall back to legacy :foo RegExp if necessary

@@ -97,3 +93,3 @@ matcher = regexps.colon.test(route.route) ? regexps.colon : regexps.curlies;

// Remove matching default values
each(route.defaults, function (val, name) {
canReflect.eachKey(route.defaults, function (val, name) {
if (cpy[name] === val) {

@@ -114,3 +110,3 @@ delete cpy[name];

// If no route was found, there is no hash URL, only paramters.
return isEmptyObject(data) ? "" :bindingProxy.call("querySeparator") + param(data);
return canReflect.size(data) === 0 ? "" :bindingProxy.call("querySeparator") + param(data);
}

@@ -117,0 +113,0 @@

// This file contains the function that allows the registration of routes
var diff = require('can-util/js/diff/diff');
var diffObject = require('can-util/js/diff-object/diff-object');
var canReflect = require("can-reflect");
var dev = require('can-util/js/dev/dev');
var each = require('can-util/js/each/each');
var dev = require('can-log/dev/dev');
var bindingProxy = require("./binding-proxy");
var regexps = require("./regexps");
var diff = require('can-util/js/diff/diff');
var diffObject = require('can-util/js/diff-object/diff-object');
// `RegExp` used to match route variables of the type '{name}'.

@@ -77,3 +78,3 @@ // Any word character or a period is matched.

// warn if new route uses same map properties as an existing route
each(RouteRegistry.routes, function(r) {
canReflect.eachKey(RouteRegistry.routes, function(r) {
var existingKeys = r.names.concat(Object.keys(r.defaults)).sort();

@@ -80,0 +81,0 @@ var keys = names.concat(Object.keys(defaults)).sort();

var bindingProxy = require("./binding-proxy");
var routeDeparam = require("./deparam");
var routeParam = require("./param");
var assign = require("can-util/js/assign/assign");
var each = require('can-util/js/each/each');
var canReflect = require("can-reflect");
var string = require('can-util/js/string/string');

@@ -12,3 +10,3 @@

var tags = [];
each(props, function (val, name) {
canReflect.eachKey(props, function (val, name) {
tags.push((name === 'className' ? 'class' : name) + '="' +

@@ -38,3 +36,3 @@ (name === "href" ? val : string.esc(val)) + '"');

var baseOptions = routeDeparam(bindingProxy.call("can.getValue"));
options = assign(assign({}, baseOptions), options);
options = canReflect.assignMap(canReflect.assignMap({}, baseOptions), options);
}

@@ -137,3 +135,3 @@ return bindingProxy.call("root") +routeParam(options);

return "<a " + makeProps(
assign({
canReflect.assignMap({
href: canRoute_url(options, merge)

@@ -140,0 +138,0 @@ }, props)) + ">" + name + "</a>";

var canRoute = require('can-route');
var QUnit = require('steal-qunit');
var dev = require('can-util/js/dev/dev');
var dev = require('can-log/dev/dev');

@@ -21,3 +21,3 @@ QUnit.module("can-route .param and .deparam",{

page: "can.Control"
});
}, "deparam");
QUnit.equal(canRoute.rule("can.Control"), "{page}");

@@ -24,0 +24,0 @@

@@ -6,3 +6,4 @@ /* jshint asi:true */

var DefineMap = require('can-define/map/map');
var makeArray = require('can-util/js/make-array/make-array');
var canReflect = require('can-reflect');
var mockRoute = require("./mock-route-binding");

@@ -31,3 +32,3 @@

window.routeTestReady = function(){
var args = makeArray(arguments)
var args = canReflect.toArray(arguments)
args.unshift(iframe);

@@ -34,0 +35,0 @@ callback.apply(null, args);

@@ -5,5 +5,5 @@ /* jshint asi:true */

var QUnit = require('steal-qunit');
var makeArray = require('can-util/js/make-array/make-array');
var dev = require('can-util/js/dev/dev');
var CanMap = require("can-map");
var canReflect = require('can-reflect');
QUnit.module("can/route with can-map", {

@@ -26,3 +26,3 @@ setup: function () {

window.routeTestReady = function(iCanRoute){
var args = makeArray(arguments)
var args = canReflect.toArray(arguments)
args.unshift(iframe);

@@ -29,0 +29,0 @@ callback.apply(null, args);

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