Skip to content

Commit

Permalink
Added support for assigning an array used in a forloop.
Browse files Browse the repository at this point in the history
  • Loading branch information
michielvandergeest committed Feb 22, 2024
1 parent 9b5f919 commit 782898f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/reactivity/reactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ const reactiveProxy = (target) => {
set(target, key, value, receiver) {
const oldValue = target[key]

const result = Reflect.set(target, key, value, receiver)
let result
if (typeof value === 'object' && Array.isArray(value) && proxyMap.get(target[key])) {
result = target[key].splice(0, target[key].length, ...value)
} else {
result = Reflect.set(target, key, value, receiver)
}

if (typeof result === 'object') {
if (typeof value === 'object') {
reactiveProxy(target[key])
}

Expand Down Expand Up @@ -104,6 +109,7 @@ const reactiveDefineProperty = (target) => {
return internalValue
},
set(newValue) {
// todo: support assigning array (as we do with proxies)
let oldValue = internalValue
if (oldValue !== newValue) {
internalValue = newValue
Expand Down

0 comments on commit 782898f

Please sign in to comment.