Skip to content

Commit

Permalink
Remove undocumented support for passing no node
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 4, 2023
1 parent 1a4f304 commit b6afd5a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import {webNamespaces} from 'web-namespaces'
* Equivalent hast node.
*/
export function fromDom(tree, options) {
const result = tree ? transform(tree, options || {}) : undefined
return result || {type: 'root', children: []}
return transform(tree, options || {}) || {type: 'root', children: []}
}

/**
Expand Down
9 changes: 0 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@ test('fromDom', async function (t) {
assert.deepEqual(fromDom(frag), {type: 'root', children: []})
})

await t.test('should handle a missing DOM tree', async function () {
assert.deepEqual(
// To do: remove.
// @ts-expect-error runtime.
fromDom(),
{type: 'root', children: []}
)
})

await t.test('should support a text w/o value', async function () {
assert.deepEqual(fromDom(document.createTextNode('')), {
type: 'text',
Expand Down

0 comments on commit b6afd5a

Please sign in to comment.