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

can-route-pushstate

Package Overview
Dependencies
Maintainers
7
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-route-pushstate - npm Package Compare versions

Comparing version 4.0.0-pre.6 to 4.0.0-pre.7

45

can-route-pushstate_test.js

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

deepEqual(obj, {
page: "can.Control",
route: "{page}"
page: "can.Control"
});

@@ -38,4 +37,3 @@

deepEqual(obj, {
page: "index",
route: "{page}"
page: "index"
});

@@ -46,4 +44,3 @@

page: "can.Control",
where: "there",
route: "{page}"
where: "there"
});

@@ -61,4 +58,3 @@

index: "foo",
where: "there",
route: "{page}/{index}"
where: "there"
});

@@ -88,4 +84,3 @@ });

var2: 'val2',
var3: 'val3',
route: "pages/{var1}/{var2}/{var3}"
var3: 'val3'
});

@@ -232,4 +227,4 @@ })

var obj = route.deparam(res);
delete obj.route
deepEqual(obj, data)
deepEqual(obj, data, "{page}/{type} with query string");
data = {

@@ -243,5 +238,5 @@ page: "can.Control",

obj = route.deparam(res);
delete obj.route;
deepEqual(data, obj);
deepEqual(data, obj, "{page}/{type} with query string");
data = {

@@ -266,3 +261,3 @@ page: " a ",

delete obj.route;
deepEqual(data, obj);
deepEqual(data, obj, "/{page}/{type} starting slash with removed defaults");

@@ -297,4 +292,3 @@ route.routes = {};

foo: 1,
bar: 2,
route: "{foo}/{bar}"
bar: 2
})

@@ -312,4 +306,3 @@ })

deepEqual(obj, {
who: "can.Control",
route: "{who}"
who: "can.Control"
});

@@ -319,4 +312,3 @@

deepEqual(obj, {
search: "can.Control",
route: "search/{search}"
search: "can.Control"
}, "bad deparam");

@@ -981,4 +973,3 @@

deepEqual(obj, {
foo: "bar",
route: ""
foo: "bar"
});

@@ -994,4 +985,3 @@ });

deepEqual(obj, {
foo: "abc",
route: "{foo}"
foo: "abc"
});

@@ -1040,3 +1030,3 @@ });

route.routes = {};
route("{foo}-{bar}");
route.register("{foo}-{bar}");

@@ -1046,4 +1036,3 @@ var obj = route.deparam("abc-def");

foo: "abc",
bar: "def",
route: "{foo}-{bar}"
bar: "def"
});

@@ -1050,0 +1039,0 @@ });

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

// # can/route/pushstate/pushstate.js
// # can-route-pushstate.js
//

@@ -12,13 +12,18 @@ // Plugin for `route` which uses browser `history.pushState` support

"use strict";
var route = require('can-route');
var bindingProxy = require("can-route/src/binding-proxy");
var canReflect = require("can-reflect");
var KeyTree = require("can-key-tree");
var isNode = require('can-util/js/is-node/is-node');
var extend = require('can-util/js/assign/assign');
var each = require('can-util/js/each/each');
var diffObject = require('can-util/js/diff-object/diff-object');
var queues = require("can-queues");
var SimpleObservable = require("can-simple-observable");
var isNode = require('can-globals/is-node/is-node');
var LOCATION = require('can-globals/location/location');
var domEvents = require('can-util/dom/events/events');
require("can-util/dom/events/delegate/delegate");
var route = require('can-route');
var domEvents = require('can-dom-events');
var diffObject = require('can-util/js/diff-object/diff-object');
var hasPushstate = window.history && window.history.pushState;

@@ -28,9 +33,3 @@ var loc = LOCATION();

var usePushStateRouting = hasPushstate && loc && validProtocols[loc.protocol];
var canReflect = require("can-reflect");
var KeyTree = require("can-key-tree");
var bindingProxy = require("can-route/src/binding-proxy");
var queues = require("can-queues");
var SimpleObservable = require("can-simple-observable");
// Original methods on `history` that will be overwritten

@@ -140,3 +139,3 @@ var methodsToOverwrite = ['pushState', 'replaceState'];

anchorClickHandler: function (node, e) {
if (!(e.isDefaultPrevented ? e.isDefaultPrevented() : e.defaultPrevented === true)) {

@@ -170,7 +169,5 @@ // Fix for IE showing blank host, but blank host means current host.

var url = nodePathWithSearch.substr(root.length);
// If a route matches update the data.
var curParams = route.deparam(url);
// If we've matched a route
if (curParams.hasOwnProperty('route')) {
if (route.rule(url) !== undefined) {
// Makes it possible to have a link with a hash.

@@ -209,7 +206,7 @@ // Calling .pushState will dispatch events, causing

// Intercept routable links.
domEvents.addDelegateListener.call(document.documentElement, 'click', 'a', this.anchorClickHandler);
domEvents.addDelegateListener(document.documentElement, 'click', 'a', this.anchorClickHandler);
var originalMethods = this.originalMethods = {};
var dispatchHandlers = this.dispatchHandlers;
// Rewrites original `pushState`/`replaceState` methods on `history` and keeps pointer to original methods
each(methodsToOverwrite, function (method) {
canReflect.eachKey(methodsToOverwrite, function (method) {
this.originalMethods[method] = window.history[method];

@@ -231,12 +228,12 @@ window.history[method] = function (state, title, url) {

// Bind to `popstate` event, fires on back/forward.
domEvents.addEventListener.call(window, 'popstate', this.dispatchHandlers);
domEvents.addEventListener(window, 'popstate', this.dispatchHandlers);
},
teardown: function(){
domEvents.removeEventListener.call(document.documentElement, 'click', 'a', this.anchorClickHandler);
domEvents.removeEventListener(document.documentElement, 'click', 'a', this.anchorClickHandler);
each(methodsToOverwrite, function (method) {
canReflect.eachKey(methodsToOverwrite, function (method) {
window.history[method] = this.originalMethods[method];
}, this);
domEvents.removeEventListener.call(window, 'popstate', this.dispatchHandlers);
domEvents.removeEventListener(window, 'popstate', this.dispatchHandlers);
},

@@ -315,3 +312,3 @@ get: getCurrentUrl,

extend(route, {
canReflect.assignMap(route, {
replaceStateOn: function() {

@@ -318,0 +315,0 @@ canReflect.addValues( options.replaceStateKeys, canReflect.toArray(arguments) );

{
"name": "can-route-pushstate",
"version": "4.0.0-pre.6",
"version": "4.0.0-pre.7",
"description": "Pushstate for can-route",

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

"dependencies": {
"can-dom-events": "^1.0.0",
"can-dom-events": "^1.1.0",
"can-globals": "<2.0.0",

@@ -41,3 +41,3 @@ "can-key-tree": "<2.0.0",

"can-reflect": "^1.8.0",
"can-route": "^4.0.0-pre.15",
"can-route": "^4.0.0-pre.18",
"can-simple-observable": "^2.0.0-pre.28",

@@ -44,0 +44,0 @@ "can-util": "^3.9.0"

Sorry, the diff of this file is not supported yet

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