Skip to content

Commit

Permalink
Modernizing (lol) to use popstate event; this.history[] will keep…
Browse files Browse the repository at this point in the history
… track of the nav history, updating README.md
  • Loading branch information
avoidwork committed Apr 16, 2021
1 parent c79573a commit c19552e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ Multi-tier routing delimiter, defaults to `/`, e.g. `#settings/billing`; each ti

## API
#### current()
Returns the current `Route`, if logging is enabled
Returns the current `Route`; if logging is enabled the trigger `Element` will be present

#### popstate(ev)
Event handler, expects `{oldURL: "", newURL: ""}`
#### popstate()
Event handler

#### scan(default)
Scans `ctx` for routes & resets `default` which is an optional argument, otherwise it defaults to the first route
Expand All @@ -108,6 +108,7 @@ Context specific DOM selector

## Requirements
- `Element.classList` API, or shim
- `popstate` Event

## License
Copyright (c) 2021 Jason Mulligan
Expand Down
2 changes: 1 addition & 1 deletion lib/dom-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

if (!has(this.css.hidden, this.ctx.classList)) {
if (hash.length > 0 && includes(this.routes, hash)) {
this.handler({oldURL: "", newURL: document.location.hash});
this.handler();
} else {
this.route(this.start);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dom-router.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/dom-router.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

if (!has(this.css.hidden, this.ctx.classList)) {
if (hash.length > 0 && includes(this.routes, hash)) {
this.handler({oldURL: "", newURL: document.location.hash});
this.handler();
} else {
this.route(this.start);
}
Expand Down
2 changes: 1 addition & 1 deletion test/www/dom-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

if (!has(this.css.hidden, this.ctx.classList)) {
if (hash.length > 0 && includes(this.routes, hash)) {
this.handler({oldURL: "", newURL: document.location.hash});
this.handler();
} else {
this.route(this.start);
}
Expand Down

0 comments on commit c19552e

Please sign in to comment.