@katabatic/runtime 1.1.3 → 1.1.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@katabatic/runtime",
3
3
  "license": "MIT",
4
- "version": "1.1.3",
4
+ "version": "1.1.4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
package/src/eachBlock.js CHANGED
@@ -67,7 +67,7 @@ export class EachBlock extends Map {
67
67
  init() {
68
68
  this.#effect = new Effect(
69
69
  () => {
70
- const iterable = this.getIterable()
70
+ const iterable = [...this.getIterable() ?? []]
71
71
 
72
72
  for (const block of this.#getRemovedBlocks(iterable)) {
73
73
  this.#removeBlock(block)
@@ -139,9 +139,8 @@ class Block extends AnimatedClient {
139
139
  anchor
140
140
 
141
141
  setValue(nextValue) {
142
- const hasChange = this.value !== nextValue
143
- this.value = nextValue
144
- if (hasChange) {
142
+ if (this.value !== nextValue) {
143
+ this.value = nextValue
145
144
  this.signal.dispatchEvent(new SignalEvent('changed'))
146
145
  }
147
146
  }
package/src/index.js CHANGED
@@ -21,6 +21,7 @@ export function $$(customElement) {
21
21
 
22
22
  const client = new Client()
23
23
  const signal = new Signal(customElement)
24
+ const bindings = new WeakMap()
24
25
 
25
26
  client.boundary = function (fn) {
26
27
  const boundary = new Boundary(fn, { orphaned: true }).init()
@@ -97,6 +98,26 @@ export function $$(customElement) {
97
98
  }
98
99
  }
99
100
 
101
+ client.bind = function(element, fn, _client) {
102
+ function opts(value) {
103
+ return {...value, getBinding: client.getBinding}
104
+ }
105
+
106
+ const binding = fn(opts)
107
+ bindings.set(element, binding)
108
+ _client.add(binding)
109
+ return binding
110
+ }
111
+
112
+ client.getBinding = function (element) {
113
+ let binding = bindings.get(element)
114
+ if (!binding) {
115
+ binding = {}
116
+ bindings.set(element, binding)
117
+ }
118
+ return binding
119
+ }
120
+
100
121
  return client
101
122
  }
102
123