Skip to content

Commit

Permalink
Fix touch backend bug in _getDropTargetId (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-bondarenko committed May 27, 2020
1 parent d82be21 commit 7ec5c37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/touch-backend/src/TouchBackendImpl.ts
Expand Up @@ -563,8 +563,8 @@ export class TouchBackendImpl implements Backend {
public _getDropTargetId = (node: Element): Identifier | undefined => {
const keys = this.targetNodes.keys()
let next = keys.next()
const targetId = next.value
while (next.done === false) {
const targetId = next.value
if (node === this.targetNodes.get(targetId)) {
return targetId
} else {
Expand Down
Expand Up @@ -19,11 +19,14 @@ describe('TouchBackend', () => {
})

it('can determine target ids', () => {
const mockNode = {} as HTMLElement
const mockNode1 = {} as HTMLElement
const mockNode2 = {} as HTMLElement
const backend = TouchBackend(mockManager(), {}, {}) as TouchBackendImpl
backend.targetNodes.set('abc', mockNode)
backend.targetNodes.set('abc', mockNode1)
backend.targetNodes.set('def', mockNode2)

expect(backend._getDropTargetId(mockNode)).toEqual('abc')
expect(backend._getDropTargetId(mockNode1)).toEqual('abc')
expect(backend._getDropTargetId(mockNode2)).toEqual('def')
expect(backend._getDropTargetId({} as Element)).toEqual(undefined)
})
})
Expand Down

0 comments on commit 7ec5c37

Please sign in to comment.