Skip to content

Commit

Permalink
polyfill toSpliced for older Node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed May 26, 2024
1 parent 05eb22c commit e8beb1a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/@headlessui-react/src/hooks/use-hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ let hierarchyStores = new DefaultMap(() =>
},
REMOVE(id: string) {
let idx = this.indexOf(id)
return idx === -1 ? this : this.toSpliced(idx, 1)
if (idx === -1) return this
let copy = this.slice()
copy.splice(idx, 1)
return copy
},
})
)
Expand Down

0 comments on commit e8beb1a

Please sign in to comment.