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

can-route-pushstate

Package Overview
Dependencies
Maintainers
1
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 3.0.0-pre.5 to 3.0.0-pre.6

35

can-route-pushstate.md
@module {Object} can-route-pushstate
@parent can-core
@download can/route/pushstate
@link ../docco/route/pushstate/pushstate.html docco
@description Changes [can-route](https://github.com/canjs/can-route) to use
@description Changes [can-route] to use
[pushstate](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history)

@@ -28,9 +26,9 @@ to change the window's [pathname](https://developer.mozilla.org/en-US/docs/Web/API/URLUtils.pathname) instead

The pushstate plugin uses the same API as [can-route]. To start using pushstate plugin all you need is to import `can-route-pushstate`, it will set itself as default binding on [can.route].
can-route-pushstate uses the same API as [can-route]. To start using can-route-pushstate all you need is to import `can-route-pushstate`, it will set itself as default binding on [can-route].
You can check current binding by inspecting `route.currentBinding`, the default value is `"hashchange"`.
You can check current binding by inspecting `route.currentBinding`; the default value is `"hashchange"`.
### Creating and changing routes
To [create](route.html#section_CreatingaRoute) route use `route(url, defaults)` like:
To create routes use `route(url, defaults)` like:

@@ -41,6 +39,7 @@ ```js

route("books/:genre/:author");
route.ready(); // do not forget to initialize can-route
route.ready(); // Initializes can-route
```
Do not forget to [initialize](route.ready.html) can-route after creating all routes, do it by calling `route.ready()`.
Do not forget to [can-route.ready initialize] can-route after creating all routes, do it by calling `route.ready()`.

@@ -90,21 +89,7 @@ List of defined routes is contained in `route.routes`, you can examine current route state by calling:

As can-route is basically a [can-map] that represents `window.location.pathname`, you can bind on it in the same way you would on any can.Map object.
As can-route contains a map that represents `window.location.pathname`, you can bind on it.
To listen on any changes on `route` use `route.bind('change', callback)`, the following params will be passed to callback function:
To bind to specific attributes on can-route:
```js
route.bind('change', function(ev, attr, how, newVal, oldVal) {
//-> ev: {EventObject}
//-> attr: 'username'
//-> how: 'change'
//-> newVal: 'veljko'
//-> oldVal: undefined
});
route.attr({username: 'veljko'}, true);
```
You can also bind to specific attribute on can-route:
```js
route.bind('username', function(ev, newVal, oldVal) {

@@ -121,3 +106,3 @@ //-> ev: {EventObject}

Pushstate plugin has one additional property, `route.bindings.pushstate.root`, which specifies the part of that pathname that should not change. For example, if we only want to have pathnames within `http://example.com/contacts/`, we can specify a root like:
can-route-pushstate has one additional property, `route.bindings.pushstate.root`, which specifies the part of that pathname that should not change. For example, if we only want to have pathnames within `http://example.com/contacts/`, we can specify a root like:

@@ -124,0 +109,0 @@ ```js

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

@@ -5,0 +5,0 @@ "homepage": "https://canjs.com",

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