Skip to content

Commit

Permalink
refactor: remove elementKeyAttribute (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
piecyk committed Sep 5, 2023
1 parent 8ddf939 commit d7df662
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/virtual-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ export interface VirtualizerOptions<
rangeExtractor?: (range: Range) => number[]
scrollMargin?: number
scrollingDelay?: number
elementKeyAttribute?: string
indexAttribute?: string
initialMeasurementsCache?: VirtualItem[]
lanes?: number
Expand Down Expand Up @@ -347,7 +346,6 @@ export class Virtualizer<
scrollMargin: 0,
scrollingDelay: 150,
indexAttribute: 'data-index',
elementKeyAttribute: 'data-element-key',
initialMeasurementsCache: [],
lanes: 1,
...opts,
Expand Down Expand Up @@ -623,9 +621,7 @@ export class Virtualizer<
) => {
const index = this.indexFromElement(node)

const elementKey =
node.getAttribute(this.options.elementKeyAttribute) ??
this.options.getItemKey(index)
const elementKey = this.options.getItemKey(index)

const prevNode = this.measureElementCache.get(elementKey)

Expand Down Expand Up @@ -653,6 +649,7 @@ export class Virtualizer<
resizeItem = (index: number, size: number) => {
const item = this.measurementsCache[index]
if (!item) {
console.warn(`Missing virtual item for index = ${index}`)
return
}

Expand Down

0 comments on commit d7df662

Please sign in to comment.