@symbo.ls/create 2.10.280 → 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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/package.json +2 -2
  3. package/router.js +7 -8
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.280",
3
+ "version": "2.10.286",
4
4
  "license": "MIT",
5
- "gitHead": "ed4dd56c46e6ac4dbb1df4320e87070ee1e38d8b",
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 = (root, options) => {
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(el, url, {})
25
+ if (el.routes) router(url, el, {})
26
26
  }
27
27
 
28
28
  if (routerOptions.initRouter) {
29
- if (root.on) {
30
- root.on.renderRouter = onRender
29
+ if (rootElement.on) {
30
+ rootElement.on.renderRouter = onRender
31
31
  } else {
32
- root.on = {
32
+ rootElement.on = {
33
33
  renderRouter: onRender
34
34
  }
35
35
  }
@@ -40,16 +40,15 @@ export const initRouter = (root, options) => {
40
40
  return routerOptions
41
41
  }
42
42
 
43
-
44
43
  let popStateFired
45
- export const popStateRouter = (root, options) => {
44
+ export const popStateRouter = (rootElement, options) => {
46
45
  if (popStateFired) return
47
46
  const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS
48
47
  if (!routerOptions.popState) return
49
48
  const router = (options.snippets && options.snippets.router) ? options.snippets.router : defaultRouter
50
49
  const { pathname, hash } = window.location
51
50
  const url = pathname + hash
52
- window.onpopstate = e => router(root, url, { pushState: false, level: 0 })
51
+ window.onpopstate = e => router(url, rootElement, { pushState: false, level: 0 })
53
52
  popStateFired = true
54
53
  }
55
54