jails-js 6.9.10 → 6.9.11
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/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/jails.js +1 -1
- package/dist/jails.js.map +1 -1
- package/package.json +1 -1
- package/src/component.ts +3 -2
- package/src/element.ts +1 -8
- package/src/index.ts +5 -3
package/src/component.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Idiomorph } from 'idiomorph/dist/idiomorph.esm'
|
|
|
2
2
|
import { safe, g, dup } from './utils'
|
|
3
3
|
import { publish, subscribe } from './utils/pubsub'
|
|
4
4
|
|
|
5
|
-
export const Component = ({ name, module, dependencies, node, templates, signal
|
|
5
|
+
export const Component = ({ name, module, dependencies, node, templates, signal }) => {
|
|
6
6
|
|
|
7
7
|
let tick
|
|
8
8
|
let preserve = []
|
|
@@ -11,6 +11,7 @@ export const Component = ({ name, module, dependencies, node, templates, signal,
|
|
|
11
11
|
let observer = null
|
|
12
12
|
let effect = null
|
|
13
13
|
|
|
14
|
+
const register = globalThis.__jails__.instances
|
|
14
15
|
const _model = module.model || {}
|
|
15
16
|
const initialState = (new Function( `return ${node.getAttribute('html-model') || '{}'}`))()
|
|
16
17
|
const tplid = node.getAttribute('tplid')
|
|
@@ -244,8 +245,8 @@ export const Component = ({ name, module, dependencies, node, templates, signal,
|
|
|
244
245
|
node.querySelectorAll('[tplid]')
|
|
245
246
|
.forEach((element) => {
|
|
246
247
|
const child = register.get(element)
|
|
247
|
-
const scope = { ...child.__scope__ }
|
|
248
248
|
if(!child) return
|
|
249
|
+
const scope = { ...child.__scope__ }
|
|
249
250
|
child.state.protected().forEach( key => delete data[key] )
|
|
250
251
|
const useEffect = child.effect()
|
|
251
252
|
if( useEffect ) {
|
package/src/element.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Component } from './component'
|
|
2
2
|
|
|
3
|
-
const register = new WeakMap()
|
|
4
|
-
|
|
5
3
|
export const Element = ({ component, templates, start }) => {
|
|
6
4
|
|
|
7
5
|
const { name, module, dependencies } = component
|
|
@@ -26,8 +24,7 @@ export const Element = ({ component, templates, start }) => {
|
|
|
26
24
|
module,
|
|
27
25
|
dependencies,
|
|
28
26
|
templates,
|
|
29
|
-
signal: this.abortController.signal
|
|
30
|
-
register
|
|
27
|
+
signal: this.abortController.signal
|
|
31
28
|
})
|
|
32
29
|
|
|
33
30
|
if ( rtrn && rtrn.constructor === Promise ) {
|
|
@@ -45,7 +42,3 @@ export const Element = ({ component, templates, start }) => {
|
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
export const getInstance = ( node ) => {
|
|
50
|
-
return register.get(node)
|
|
51
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Element
|
|
1
|
+
import { Element } from './element'
|
|
2
2
|
import { template, templateConfig as config } from './template-system'
|
|
3
3
|
|
|
4
4
|
globalThis.__jails__ = globalThis.__jails__ || { components: {} }
|
|
5
|
-
globalThis.__jails__.
|
|
5
|
+
globalThis.__jails__.instances = globalThis.__jails__.instances || new WeakMap()
|
|
6
|
+
globalThis.__jails__.getInstance = (node) => {
|
|
7
|
+
return globalThis.__jails__.instances.get(node)
|
|
8
|
+
}
|
|
6
9
|
|
|
7
|
-
export { getInstance }
|
|
8
10
|
export { publish, subscribe } from './utils/pubsub'
|
|
9
11
|
|
|
10
12
|
export const templateConfig = (options) => {
|