@symbo.ls/create 2.10.278 → 2.10.286
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +2 -2
- package/router.js +10 -7
package/index.js
CHANGED
|
@@ -70,7 +70,7 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
70
70
|
|
|
71
71
|
applyInspectListener(domqlApp, options)
|
|
72
72
|
popStateRouter(domqlApp, options)
|
|
73
|
-
|
|
73
|
+
if (options.on && options.on.create) options.on.create(domqlApp, options)
|
|
74
74
|
fetchAsync(domqlApp, key, options)
|
|
75
75
|
|
|
76
76
|
return domqlApp
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/create",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.286",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "bcff4f38fa5f1356e93c5b7c33ad53ce5a3c4cb6",
|
|
6
6
|
"source": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"dependencies": {
|
package/router.js
CHANGED
|
@@ -11,7 +11,7 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
11
11
|
popState: true
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const initRouter = (
|
|
14
|
+
export const initRouter = (rootElement, options) => {
|
|
15
15
|
let routerOptions = merge(options.routerOptions || {}, DEFAULT_ROUTING_OPTIONS)
|
|
16
16
|
|
|
17
17
|
if (routerOptions === false) return
|
|
@@ -22,14 +22,14 @@ export const initRouter = (root, options) => {
|
|
|
22
22
|
const onRender = (el, s) => {
|
|
23
23
|
const { pathname, hash } = window.location
|
|
24
24
|
const url = pathname + hash
|
|
25
|
-
if (el.routes) router(
|
|
25
|
+
if (el.routes) router(url, el, {})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (routerOptions.initRouter) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
29
|
+
if (rootElement.on) {
|
|
30
|
+
rootElement.on.renderRouter = onRender
|
|
31
31
|
} else {
|
|
32
|
-
|
|
32
|
+
rootElement.on = {
|
|
33
33
|
renderRouter: onRender
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -40,13 +40,16 @@ export const initRouter = (root, options) => {
|
|
|
40
40
|
return routerOptions
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
let popStateFired
|
|
44
|
+
export const popStateRouter = (rootElement, options) => {
|
|
45
|
+
if (popStateFired) return
|
|
44
46
|
const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS
|
|
45
47
|
if (!routerOptions.popState) return
|
|
46
48
|
const router = (options.snippets && options.snippets.router) ? options.snippets.router : defaultRouter
|
|
47
49
|
const { pathname, hash } = window.location
|
|
48
50
|
const url = pathname + hash
|
|
49
|
-
window.onpopstate = e => router(
|
|
51
|
+
window.onpopstate = e => router(url, rootElement, { pushState: false, level: 0 })
|
|
52
|
+
popStateFired = true
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export const injectRouterInLinkComponent = (routerOptions) => {
|