can-route
Advanced tools
Comparing version 3.2.4 to 3.3.0
@@ -10,2 +10,3 @@ /*jshint -W079 */ | ||
var deparam = require('can-deparam'); | ||
var devLog = require('can-log/dev/dev'); | ||
var each = require('can-util/js/each/each'); | ||
@@ -317,3 +318,3 @@ var string = require('can-util/js/string/string'); | ||
// setState is called typically by hashchange which fires asynchronously | ||
// So it's possible that someone started changing the data before the | ||
// So it’s possible that someone started changing the data before the | ||
// hashchange event fired. For this reason, it will not set the route data | ||
@@ -417,3 +418,3 @@ // if the data is changing or the hash already matches the hash that was set. | ||
}); | ||
// If we have a route name in our `canRoute` data, and it's | ||
// If we have a route name in our `canRoute` data, and it’s | ||
// just as good as what currently matches, use that | ||
@@ -483,4 +484,4 @@ if (canRoute.routes[routeName] && matchesData(canRoute.routes[routeName], data) === matches) { | ||
* | ||
* It's important to make sure the hash or exclamation point is not passed | ||
* to `route.deparam` otherwise it will be included in the first property's | ||
* It’s important to make sure the hash or exclamation point is not passed | ||
* to `route.deparam` otherwise it will be included in the first property’s | ||
* name. | ||
@@ -589,5 +590,5 @@ * | ||
* @parent can-route.static | ||
* @description Initializes can-route. | ||
* @deprecated {3.3} Use [can-route.start start()] instead. | ||
* | ||
* Initializes can-route. | ||
* | ||
* @signature `route.ready()` | ||
@@ -620,2 +621,42 @@ * | ||
ready: function (val) { | ||
//!steal-remove-start | ||
devLog.warn('ready() is deprecated; use start() instead'); | ||
//!steal-remove-end | ||
canRoute.start(); | ||
return canRoute; | ||
}, | ||
/** | ||
* @function can-route.start start | ||
* @parent can-route.static | ||
* @release 3.3 | ||
* | ||
* Initializes can-route. | ||
* | ||
* @signature `route.start()` | ||
* | ||
* Sets up the two-way binding between the hash and the can-route observable | ||
* map and sets the route map to its initial values. | ||
* | ||
* ```js | ||
* route("{page}", { page: "home" })); | ||
* | ||
* route.start(); | ||
* route.data.page; // -> "home" | ||
* ``` | ||
* | ||
* @return {can-route} The can-route object. | ||
* | ||
* @body | ||
* | ||
* ## Use | ||
* | ||
* After setting all your routes, call `route.start()`. | ||
* | ||
* ```js | ||
* route("overview/{dateStart}-{dateEnd}"); | ||
* route("{type}/{id}"); | ||
* route.start(); | ||
* ``` | ||
*/ | ||
start: function (val) { | ||
if (val !== true) { | ||
@@ -635,3 +676,3 @@ canRoute._setup(); | ||
* | ||
* Make a URL fragment that when set to window.location.hash will update can-route's properties | ||
* Make a URL fragment that when set to window.location.hash will update can-route’s properties | ||
* to match those in `data`. | ||
@@ -686,3 +727,3 @@ * | ||
* | ||
* Make an anchor tag (`<A>`) that when clicked on will update can-route's | ||
* Make an anchor tag (`<A>`) that when clicked on will update can-route’s | ||
* properties to match those in `data`. | ||
@@ -765,3 +806,3 @@ * | ||
* | ||
* Checks the page's current URL to see if the route represents the options | ||
* Checks the page’s current URL to see if the route represents the options | ||
* passed into the function. | ||
@@ -805,4 +846,4 @@ * | ||
// Gets the part of the url we are determinging the route from. | ||
// For hashbased routing, it's everything after the #, for | ||
// pushState it's configurable | ||
// For hashbased routing, it’s everything after the #, for | ||
// pushState it’s configurable | ||
matchingPartOfURL: function () { | ||
@@ -825,3 +866,3 @@ var loc =canRoute.location || location; | ||
currentBinding: null, | ||
// ready calls setup | ||
// start calls setup | ||
// setup binds and listens to data changes | ||
@@ -900,3 +941,3 @@ // bind listens to whatever you should be listening to | ||
each(['addEventListener','removeEventListener','bind', 'unbind', 'on', 'off'], function(name) { | ||
// exposing all internal canEvent evt's to canRoute | ||
// exposing all internal canEvent evt’s to canRoute | ||
canRoute[name] = function(eventName) { | ||
@@ -960,3 +1001,3 @@ if (eventName === '__url') { | ||
} | ||
// if it's a map, we make it always set strings for backwards compat | ||
// if it’s a map, we make it always set strings for backwards compat | ||
if( "attr" in data ) { | ||
@@ -963,0 +1004,0 @@ setRouteData( stringCoercingMapDecorator(data) ); |
@@ -22,3 +22,3 @@ @function can-route can-route | ||
@param {String} template the fragment identifier to match. The fragment identifier should contain characters (a-Z), optionally wrapped in braces ( { } ). Identifiers wrapped in braces are interpreted as being properties on can-route's map. Examples: | ||
@param {String} template the fragment identifier to match. The fragment identifier should contain characters (a-Z), optionally wrapped in braces ( { } ). Identifiers wrapped in braces are interpreted as being properties on can-route’s map. Examples: | ||
@@ -30,3 +30,3 @@ ```js | ||
@param {Object} [defaults] An object of default values. These defaults are applied to can-route's map when the route is matched. | ||
@param {Object} [defaults] An object of default values. These defaults are applied to can-route’s map when the route is matched. | ||
@@ -41,7 +41,7 @@ @return {can-route} | ||
To support the browser's back button and bookmarking in a JavaScript | ||
To support the browser’s back button and bookmarking in a JavaScript | ||
application, most applications use | ||
the `window.location.hash`. By | ||
changing the hash (via a link or JavaScript), | ||
one is able to add to the browser's history | ||
one is able to add to the browser’s history | ||
without changing the page. | ||
@@ -89,3 +89,3 @@ | ||
route('{page}', {page: 'home'}); | ||
route.ready(); | ||
route.start(); | ||
``` | ||
@@ -100,3 +100,3 @@ | ||
Listen to changes in history by [can-event.addEventListener listening] to | ||
changes of can-route's `matched` compute: | ||
changes of can-route’s `matched` compute: | ||
@@ -155,3 +155,3 @@ ```js | ||
route. A route is a mapping from a url to | ||
an object (that is the route's state). | ||
an object (that is the route’s state). | ||
In order to map to a specific properties in the url, | ||
@@ -165,3 +165,3 @@ prepend a colon to the name of the property like: | ||
If no routes are added, or no route is matched, | ||
can-route's data is updated with the [can-route.deparam deparamed] | ||
can-route’s data is updated with the [can-route.deparam deparamed] | ||
hash. | ||
@@ -176,3 +176,3 @@ | ||
can-route looks for matching routes and uses them | ||
to update can-route's data. | ||
to update can-route’s data. | ||
@@ -207,7 +207,7 @@ ```js | ||
After your application has created all of its routes, call [can-route.ready] | ||
to set can-route's data to match the current hash: | ||
After your application has created all of its routes, call [can-route.start] | ||
to set can-route’s data to match the current hash: | ||
```js | ||
route.ready(); | ||
route.start(); | ||
``` | ||
@@ -217,3 +217,3 @@ | ||
Typically, you don't set `location.hash` | ||
Typically, you don’t set `location.hash` | ||
directly. Instead, you can change properties on can-route | ||
@@ -250,3 +250,3 @@ like: | ||
route('{page}/{section}'); | ||
route.ready(); | ||
route.start(); | ||
@@ -263,3 +263,3 @@ route.data.page = 'contact'; | ||
route('{page}', { section: 'email' }); | ||
route.ready(); | ||
route.start(); | ||
@@ -279,3 +279,3 @@ route.data.page = 'contact'; | ||
route('{page}/{section}'); | ||
route.ready(); | ||
route.start(); | ||
@@ -295,3 +295,3 @@ route.data.page = 'two'; | ||
route('{section}'); | ||
route.ready(); | ||
route.start(); | ||
@@ -298,0 +298,0 @@ route.data.page = 'home'; |
{ | ||
"name": "can-route", | ||
"version": "3.2.4", | ||
"version": "3.3.0", | ||
"description": "", | ||
@@ -46,2 +46,3 @@ "homepage": "", | ||
"can-event": "^3.6.0", | ||
"can-log": "^0.1.2", | ||
"can-namespace": "1.0.0", | ||
@@ -62,3 +63,3 @@ "can-observation": "^3.3.1", | ||
"detect-cyclic-packages": "^1.1.0", | ||
"done-serve": "^0.2.0", | ||
"done-serve": "^1.5.0", | ||
"jshint": "^2.9.1", | ||
@@ -65,0 +66,0 @@ "steal": "^1.2.9", |
@@ -10,3 +10,3 @@ @function can-route.data data | ||
One of the biggest challenges in a complex application is getting all the different parts of the app to talk to each other simply, cleanly, and reliably. | ||
One of the biggest challenges in a complex application is getting all the different parts of the app to talk to each other simply, cleanly, and reliably. | ||
@@ -99,3 +99,3 @@ An elegant way to solve this problem is using the [Observer Pattern](http://en.wikipedia.org/wiki/Observer_pattern). A single object, which can be called [Application ViewModel](https://www.youtube.com/watch?v=LrzK4exG5Ss), holds the high level state of the application. | ||
}, | ||
// toggle selected from a comma separated list of ids | ||
@@ -131,4 +131,4 @@ set: function(val){ | ||
// call ready after the AppViewModel is fully initialized | ||
route.ready(); | ||
// call start after the AppViewModel is fully initialized | ||
route.start(); | ||
}); | ||
@@ -135,0 +135,0 @@ ``` |
@@ -496,3 +496,3 @@ /* jshint asi:true */ | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -516,3 +516,3 @@ setTimeout(function () { | ||
}); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
} | ||
@@ -546,3 +546,3 @@ var iframe = document.createElement('iframe'); | ||
}); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
setTimeout(function () { | ||
@@ -565,3 +565,3 @@ | ||
loc.hash = "#!cat/5"; | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -590,3 +590,3 @@ setTimeout(function () { | ||
loc.hash = "#!cat/5"; | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -613,3 +613,3 @@ setTimeout(function () { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{type}/{id}"); | ||
@@ -636,3 +636,3 @@ iCanRoute.attr({ | ||
iCanRoute.ready() | ||
iCanRoute.start() | ||
iCanRoute("active"); | ||
@@ -656,3 +656,3 @@ iCanRoute(""); | ||
setupRouteTest(function (iframe, iCanRoute, loc) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{type}"); | ||
@@ -696,3 +696,3 @@ iCanRoute("{type}/{id}"); | ||
setupRouteTest(function (iframe, iCanRoute, loc, win) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
var isOnTestPage = new win.ObserveInfo( | ||
@@ -721,3 +721,3 @@ function(){ | ||
iCanRoute.attr("page","test"); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -736,3 +736,3 @@ var val = win.observeReader.read({route: iCanRoute},win.observeReader.reads("route")).value; | ||
setupRouteTest(function (iframe, iCanRoute, loc) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
var hash1 = canRoute.url({ | ||
@@ -776,3 +776,3 @@ panelA: { | ||
route.map(appVM); | ||
route.ready(); | ||
route.start(); | ||
@@ -801,3 +801,3 @@ appVM.bind('action', function(ev, newVal) { | ||
route.map(appVM); | ||
route.ready(); | ||
route.start(); | ||
@@ -821,3 +821,3 @@ appVM.bind('action', function(ev, newVal) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{path}"); | ||
@@ -979,3 +979,3 @@ | ||
canRoute.map(appState); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1006,3 +1006,3 @@ canRoute.serializedCompute.bind('change', function(){ | ||
canRoute.map(appState); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1032,3 +1032,3 @@ QUnit.stop(); | ||
canRoute.map(appState); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1067,3 +1067,3 @@ QUnit.stop(); | ||
canRoute("{type}/{subtype}"); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1127,3 +1127,3 @@ equal(appState.route, undefined, "should not set route on appState"); | ||
QUnit.stop(); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1130,0 +1130,0 @@ var matchedCount = 0; |
@@ -590,3 +590,3 @@ /* jshint asi:true */ | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -610,3 +610,3 @@ setTimeout(function () { | ||
}); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
} | ||
@@ -639,3 +639,3 @@ var iframe = document.createElement('iframe'); | ||
}); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
setTimeout(function () { | ||
@@ -658,3 +658,3 @@ | ||
loc.hash = "#!cat/5"; | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -683,3 +683,3 @@ setTimeout(function () { | ||
loc.hash = "#!cat/5"; | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -706,3 +706,3 @@ setTimeout(function () { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{type}/{id}"); | ||
@@ -729,3 +729,3 @@ iCanRoute.attr({ | ||
iCanRoute.ready() | ||
iCanRoute.start() | ||
iCanRoute("active"); | ||
@@ -749,3 +749,3 @@ iCanRoute(""); | ||
setupRouteTest(function (iframe, iCanRoute, loc) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{type}"); | ||
@@ -789,3 +789,3 @@ iCanRoute("{type}/{id}"); | ||
setupRouteTest(function (iframe, iCanRoute, loc, win) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
var isOnTestPage = new win.ObserveInfo( | ||
@@ -814,3 +814,3 @@ function(){ | ||
iCanRoute.attr("page","test"); | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
@@ -829,3 +829,3 @@ var val = win.observeReader.read({route: iCanRoute},win.observeReader.reads("route")).value; | ||
setupRouteTest(function (iframe, iCanRoute, loc) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
var hash1 = canRoute.url({ | ||
@@ -868,3 +868,3 @@ panelA: { | ||
route.map(appVM); | ||
route.ready(); | ||
route.start(); | ||
@@ -893,3 +893,3 @@ appVM.bind('action', function(ev, newVal) { | ||
route.map(appVM); | ||
route.ready(); | ||
route.start(); | ||
@@ -913,3 +913,3 @@ appVM.bind('action', function(ev, newVal) { | ||
iCanRoute.ready(); | ||
iCanRoute.start(); | ||
iCanRoute("{path}"); | ||
@@ -1083,3 +1083,3 @@ | ||
canRoute("{type}/{subtype}"); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1173,3 +1173,3 @@ equal(appState.attr("route"), undefined, "should not set route on appState"); | ||
canRoute.ready(); | ||
canRoute.start(); | ||
@@ -1176,0 +1176,0 @@ try { |
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
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
102736
2863
0
12
+ Addedcan-log@^0.1.2
+ Addedcan-log@0.1.2(transitive)