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.14 to 4.0.0-pre.15

demos/counter.html

7

can-route.js

@@ -59,6 +59,6 @@ /*jshint -W079 */

timer = setTimeout(function () {
// indicate that the hash is set to look like the data
var serialized = canReflect.serialize( canRoute.data ),
route = routeParam.getMatchedRoute(serialized),
currentRouteName = matchedObservable.get(),
route = routeParam.getMatchedRoute(serialized, currentRouteName),
path = routeParam.paramFromRoute(route, serialized);

@@ -203,6 +203,9 @@

queues.batch.start();
// get teh data
var state = canRoute.deparam(hash);
delete state.route;
canReflect.assign(canRoute.data,state);
queues.batch.stop();
updateUrl();
}

@@ -209,0 +212,0 @@ }

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

@@ -5,0 +5,0 @@ "homepage": "https://canjs.com/doc/can-route.html",

@@ -60,3 +60,5 @@ // Regular expression for identifying &key=value lists.

var loc = LOCATION();
if(loc.hash !== "#" + path) {
if(!path && !loc.path) {
} else if(loc.hash !== "#" + path) {
loc.hash = "!" + path;

@@ -63,0 +65,0 @@ }

@@ -40,3 +40,3 @@ var each = require('can-util/js/each/each');

function getMatchedRoute(data) {
function getMatchedRoute(data, routeName) {
// Check if the provided data keys match the names in any routes;

@@ -48,5 +48,5 @@ // Get the one with the most matches.

matchCount,
routeName = data.route,
routeName,
propCount = 0;
delete data.route;

@@ -122,2 +122,6 @@

* @param {data} object The data to populate the route with.
* @param {String} [currentRouteName] The current route name. If provided, this
* can be used to "stick" the url to a previous route. By "stick", we mean that
* if there are multiple registered routes that match the `object`, the
* the `currentRouteName` will be used.
* @return {String} The route, with the data populated in it.

@@ -145,4 +149,4 @@ *

*/
function canRoute_param(data) {
return paramFromRoute(getMatchedRoute(data), data);
function canRoute_param(data, currentRouteName) {
return paramFromRoute(getMatchedRoute(data, currentRouteName), data);
}

@@ -149,0 +153,0 @@ module.exports = canRoute_param;

@@ -361,3 +361,3 @@ var canRoute = require('can-route');

test("param with route defined", function () {
test("param with currentRoute name", function () {
canRoute("holler")

@@ -367,5 +367,4 @@ canRoute("foo");

var res = canRoute.param({
foo: "abc",
route: "foo"
});
foo: "abc"
},"foo");

@@ -372,0 +371,0 @@ equal(res, "foo&foo=abc")

@@ -113,3 +113,3 @@ /* jshint asi:true */

test("canRoute.map: conflicting route values, hash should win", function(){
test("canRoute.map: conflicting route values, hash should win (canjs/canjs#979)", function(){
setupRouteTest(function (iframe, iCanRoute, loc) {

@@ -139,28 +139,29 @@

test("canRoute.map: route is initialized from URL first, then URL params are added from canRoute.data", function(){
setupRouteTest(function (iframe, iCanRoute, loc, win) {
test("canRoute.map: route is initialized from URL first, then URL params are added from canRoute.data (canjs/canjs#979)", function(){
QUnit.stop();
mockRoute.start();
iCanRoute("{type}/{id}");
var AppState = win.DefineMap.extend({seal: false},{});
var appState = new AppState({section: 'home'});
iCanRoute.map(appState);
loc.hash = "#!cat/5";
iCanRoute.start();
canRoute("{type}/{id}");
var AppState = DefineMap.extend({seal: false},{});
var appState = new AppState({section: 'home'});
setTimeout(function () {
canRoute.data = appState;
mockRoute.hash.set("#!cat/5"); // type and id get added ... this will call update url to add everything
canRoute.start();
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!cat/5&section=home", "same URL");
equal(appState.get("type"), "cat", "hash populates the appState");
equal(appState.get("id"), "5", "hash populates the appState");
equal(appState.get("section"), "home", "appState keeps its properties");
ok(iCanRoute.data === appState, "canRoute.data is the same as appState");
setTimeout(function () {
equal(mockRoute.hash.get(), "#cat/5&section=home", "same URL");
equal(appState.get("type"), "cat", "hash populates the appState");
equal(appState.get("id"), "5", "hash populates the appState");
equal(appState.get("section"), "home", "appState keeps its properties");
ok(canRoute.data === appState, "canRoute.data is the same as appState");
teardownRouteTest();
}, 30);
mockRoute.stop();
QUnit.start();
}, 30);
});
});

@@ -189,21 +190,21 @@

test("sticky enough routes", function () {
test("sticky enough routes (canjs#36)", function () {
setupRouteTest(function (iframe, iCanRoute, loc) {
QUnit.stop();
iCanRoute.start()
iCanRoute("active");
iCanRoute("");
mockRoute.start();
canRoute("active");
canRoute("");
loc.hash = "#!active";
mockRoute.hash.set("#active");
canRoute.start()
setTimeout(function () {
setTimeout(function () {
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!active");
var after = mockRoute.hash.get();
equal(after, "#active");
mockRoute.stop();
QUnit.start();
teardownRouteTest();
}, 30);
});
}, 30);
});

@@ -516,3 +517,3 @@

stop();
mockRoute.start()
mockRoute.start();

@@ -519,0 +520,0 @@ var AppState = DefineMap.extend({seal: false},{"*": "stringOrObservable"});

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