can-route
Advanced tools
Comparing version 3.2.3 to 3.2.4
@@ -880,11 +880,25 @@ /*jshint -W079 */ | ||
// instead act on the `canRoute.data` observe. | ||
each(['addEventListener','removeEventListener','bind', 'unbind', 'on', 'off', 'delegate', 'undelegate', 'removeAttr', 'compute', '_get', '___get','each'], function (name) { | ||
var bindToCanRouteData = function(name, args) { | ||
if (!canRoute.data[name]) { | ||
return; | ||
} | ||
return canRoute.data[name].apply(canRoute.data, args); | ||
}; | ||
each(['addEventListener','removeEventListener','bind', 'unbind', 'on', 'off'], function(name) { | ||
// exposing all internal canEvent evt's to canRoute | ||
canRoute[name] = function(eventName) { | ||
if (eventName === '__url') { | ||
return canEvent[name].apply(eventsObject, arguments); | ||
} | ||
return bindToCanRouteData(name, arguments); | ||
}; | ||
}); | ||
each(['delegate', 'undelegate', 'removeAttr', 'compute', '_get', '___get', 'each'], function (name) { | ||
canRoute[name] = function () { | ||
// `delegate` and `undelegate` require | ||
// the `can/map/delegate` plugin | ||
if (!canRoute.data[name]) { | ||
return; | ||
} | ||
return canRoute.data[name].apply(canRoute.data, arguments); | ||
return bindToCanRouteData(name, arguments); | ||
}; | ||
@@ -891,0 +905,0 @@ }); |
@@ -5,3 +5,4 @@ @function can-route can-route | ||
@test can-route/test.html | ||
@parent can-core | ||
@parent can-routing | ||
@collection can-core | ||
@link ../docco/route/route.html docco | ||
@@ -96,8 +97,8 @@ @package ./package.json | ||
Listen to changes in history by [can-event.addEventListener listening] to | ||
changes in can-route like: | ||
changes of can-route's `matched` compute: | ||
```js | ||
route.on('foo', function(ev, attr, how, newVal, oldVal) { | ||
// Foo changed! | ||
}) | ||
route.matched.on('change', function(ev, attr, how, newVal, oldVal) { | ||
// attr changed from oldVal -> newVal | ||
}); | ||
``` | ||
@@ -104,0 +105,0 @@ |
{ | ||
"name": "can-route", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "", | ||
@@ -21,3 +21,3 @@ "homepage": "", | ||
"testee": "testee test/test.html --browsers firefox", | ||
"test": "npm run jshint && npm run testee", | ||
"test": "npm run detect-cycle && npm run jshint && npm run testee", | ||
"jshint": "jshint ./*.js --config", | ||
@@ -29,3 +29,4 @@ "release:pre": "npm version prerelease && npm publish --tag pre", | ||
"build": "node build.js", | ||
"develop": "done-serve --static --develop --port 8080" | ||
"develop": "done-serve --static --develop --port 8080", | ||
"detect-cycle": "detect-cyclic-packages --ignore done-serve" | ||
}, | ||
@@ -61,2 +62,3 @@ "main": "can-route", | ||
"can-stache-key": "^0.1.0", | ||
"detect-cyclic-packages": "^1.1.0", | ||
"done-serve": "^0.2.0", | ||
@@ -63,0 +65,0 @@ "jshint": "^2.9.1", |
@@ -1096,1 +1096,43 @@ /* jshint asi:true */ | ||
}); | ||
test("triggers __url event anytime a there's a change to individual properties", function(){ | ||
mockRoute.start(); | ||
var AppState = DefineMap.extend({seal: false},{"*": "stringOrObservable"}); | ||
var appState = new AppState({}); | ||
canRoute.data = appState; | ||
canRoute('{page}'); | ||
canRoute('{page}/{section}'); | ||
QUnit.stop(); | ||
canRoute.ready(); | ||
var matchedCount = 0; | ||
canRoute.on('__url', function() { | ||
// any time a route property is changed, not just the matched route | ||
matchedCount++; | ||
}); | ||
setTimeout(function() { | ||
canRoute.data.page = 'two'; | ||
}, 30); | ||
setTimeout(function() { | ||
canRoute.data.section = 'a'; | ||
}, 60); | ||
setTimeout(function() { | ||
canRoute.data.section = 'b'; | ||
}, 90); | ||
setTimeout(function(){ | ||
// 1st call is going from undefined to empty string | ||
equal(matchedCount, 4, 'calls __url event every time a property is changed'); | ||
mockRoute.stop(); | ||
QUnit.start(); | ||
}, 200); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
101721
2822
11