-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e82cb1
commit cf95143
Showing
7 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PorpoiseRouter } from "../components/p-router.js"; | ||
import { IRouteDescriptor } from "../internals/api.js"; | ||
|
||
export function createRouter(target: string, routes: Record<string, string | IRouteDescriptor>) { | ||
const routerNode = document.querySelector(`p-router[name="${target}"]`) as PorpoiseRouter; | ||
|
||
if (routerNode) { | ||
routerNode.configure(routes); | ||
} | ||
else console.error(`Could not find <porpoise-router name="${target}"></porpoise-router> in the DOM.`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// ES5 interop with custom elements: | ||
import "./es5-adapter.js"; | ||
import { PorpoiseRouter, IRouteDescriptor } from "./porpoise-router.js"; | ||
import { pathToRegexp } from "path-to-regexp"; | ||
|
||
export default function createRouter(target: string, routes: Record<string, string | IRouteDescriptor>) { | ||
const routerNode = document.querySelector(`porpoise-router[name="${target}"]`) as PorpoiseRouter; | ||
|
||
if (routerNode) { | ||
routerNode.configure(routes); | ||
} | ||
else console.error(`Could not find <porpoise-router name="${target}"></porpoise-router> in the DOM.`); | ||
} | ||
import "./internals/es5-adapter.js"; | ||
|
||
// Register components: | ||
import "./components/p-link.js"; | ||
import "./components/p-router.js"; | ||
|
||
// Setup function: | ||
export { createRouter } from "./functions/create-router.js"; | ||
|
||
// Export typings: | ||
export * from "./internals/api.js"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IRouteDescriptor { | ||
element: string, | ||
props?: Record<string, string> | ||
} |
File renamed without changes.