@wrnrlr/prelude 0.2.3 → 0.2.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/deno.jsonc CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "exports": "./src/mod.ts",
5
5
  "compilerOptions": {
6
6
  "strict": true,
@@ -15,9 +15,9 @@ function Checkbox(props) {
15
15
  }
16
16
 
17
17
  function App() {
18
- const todos = signal([true,false])
19
- // const obj = signal({todos:[true]})
20
- // const todos = wrap(obj,'todos')
18
+ // const todos = signal([true,false])
19
+ const obj = signal({todos:[true]})
20
+ const todos = wrap(obj,'todos')
21
21
  const first = wrap(todos, 0)
22
22
  const removeItem = i => {
23
23
  // console.log('remove', i)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
3
  "type": "module",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "author": "Werner Laurensse",
6
6
  "description": "A signal based frontend library with fine-grained reactivity",
7
7
  "main": "./src/mod.ts",
@@ -82,8 +82,10 @@ export function listArray<T, U extends Mountable>(
82
82
  disposeList(items)
83
83
  })
84
84
 
85
+ let newItems
86
+
85
87
  return () => {
86
- const newItems = typeof list==='function' ? list() || [] : list;
88
+ newItems = typeof list==='function' ? list() || [] : list;
87
89
  return untrack(() => {
88
90
  if (newItems.length > 0 && fallbackDisposer) {
89
91
  fallbackDisposer();
@@ -204,10 +206,11 @@ export function listArray<T, U extends Mountable>(
204
206
  let sV = (...a) => {
205
207
  sV = (...a) => {
206
208
  if (a.length===0) {
207
- return list()[sI()]
209
+ return newItems[t.index]
208
210
  } else {
209
- const k = untrack(sI)
210
- return list(b => b.toSpliced(k, 1, typeof a[0] === 'function' ? a[0]() : a[0])).at(k)
211
+ const k = t.index
212
+ const b = newItems.toSpliced(k, 1, typeof a[0] === 'function' ? a[0]() : a[0])
213
+ return list(b).at(k)
211
214
  }
212
215
  }
213
216
  t.valueSetter = sV
package/src/runtime.ts CHANGED
@@ -339,7 +339,7 @@ function setAttribute(node: Element, name: string, value?: string): undefined {
339
339
  }
340
340
 
341
341
  function setAttributeNS(node:Node, ns:string, name:string, value?:string):void {
342
- value ? node.setAttributeNS(ns, name, value) : node.removeAttributeNS(ns, name)
342
+ value===undefined || value===null ? node.setAttributeNS(ns, name, value) : node.removeAttributeNS(ns, name)
343
343
  }
344
344
 
345
345
  function addEventListener(node: Element, name: string, handler:((e:Event)=>void), delegate:boolean): void {