@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 +1 -1
- package/example/checkbox.html +3 -3
- package/package.json +1 -1
- package/src/controlflow.ts +7 -4
- package/src/runtime.ts +1 -1
package/deno.jsonc
CHANGED
package/example/checkbox.html
CHANGED
@@ -15,9 +15,9 @@ function Checkbox(props) {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
function App() {
|
18
|
-
const todos = signal([true,false])
|
19
|
-
|
20
|
-
|
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
package/src/controlflow.ts
CHANGED
@@ -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
|
-
|
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
|
209
|
+
return newItems[t.index]
|
208
210
|
} else {
|
209
|
-
const k =
|
210
|
-
|
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 {
|