Skip to content

Commit

Permalink
Remove innerHTML check and rely on types instead. Also remove null as…
Browse files Browse the repository at this point in the history
… a valid type.
  • Loading branch information
mathiassoeholm committed May 12, 2021
1 parent 568a330 commit 987fcbf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 0 additions & 6 deletions src/__tests__/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ test('logs messsage when element is not a valid HTML', () => {
expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(
`"The element you're providing isn't a valid DOM element."`,
)
console.log.mockClear()
screen.logTestingPlaygroundURL({})
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(
`"The element you're providing isn't a valid DOM element."`,
)
})

test('logs Playground URL that are passed as element', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/playground-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ function encode(value: string) {
return compressToEncodedURIComponent(unindent(value))
}

function getPlaygroundUrl(element: Element | null) {
if (!element || !('innerHTML' in element)) {
function getPlaygroundUrl(element: Element) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!element) {
throw new Error(`The element you're providing isn't a valid DOM element.`)
}

Expand Down

0 comments on commit 987fcbf

Please sign in to comment.