Skip to content

Commit

Permalink
feat: Enable deletion on Map/Set
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurewarth0920 committed Jan 8, 2024
1 parent 221d839 commit 9a52898
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/devtools-kit/src/core/component/state/editor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MaybeRef, Ref } from 'vue'
import { isReactive, isRef } from 'vue'
import { isReactive, isRef, toRaw } from 'vue'
import { getComponentInstance } from '../general'
import { devtoolsContext } from '../../general'

Expand Down Expand Up @@ -70,6 +70,10 @@ export class StateEditor {
if (state.remove || state.newKey) {
if (Array.isArray(object))
object.splice(field as number, 1)
else if (toRaw(object) instanceof Map && typeof value === 'object' && value && 'key' in value)
object.delete(value.key)
else if (toRaw(object) instanceof Set)
object.delete(value)
else
Reflect.deleteProperty(object, field)
}
Expand Down

0 comments on commit 9a52898

Please sign in to comment.