Skip to content

Commit 00f317e

Browse files
committed
Simplify type to maybe not maybe void
1 parent 83641e9 commit 00f317e

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/paste-markdown-table.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,12 @@ function parseTable(html: string): HTMLElement | null {
9595
return el.querySelector('table')
9696
}
9797

98-
function hasTable(transfer: DataTransfer): HTMLElement | void {
99-
if (Array.from(transfer.types).indexOf('text/html') === -1) return
98+
function hasTable(transfer: DataTransfer): HTMLElement | null {
99+
if (Array.from(transfer.types).indexOf('text/html') === -1) return null
100100

101101
const html = transfer.getData('text/html')
102-
if (!/<table/i.test(html)) return
102+
if (!/<table/i.test(html)) return null
103103

104104
const table = parseTable(html)
105-
if (!table) return
106-
107-
// Prevent pasting layout table
108-
if (table.closest('[data-paste-markdown-skip]')) return
109-
110-
return table
105+
return !table || table.closest('[data-paste-markdown-skip]') ? null : table
111106
}

0 commit comments

Comments
 (0)