Skip to content

Commit

Permalink
Change to remove support for non-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 2, 2023
1 parent 5088642 commit 075e725
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
26 changes: 8 additions & 18 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,18 @@ const meta = convertElement('meta')
/**
* Check if the given value is *phrasing* content.
*
* @param {unknown} value
* Thing to check, typically `Node`.
* @param {Nodes} value
* Node to check.
* @returns {boolean}
* Whether `value` is phrasing content.
*/
export function phrasing(value) {
return Boolean(
node(value) &&
(value.type === 'text' ||
basic(value) ||
embedded(value) ||
// @ts-expect-error: To do: update `hast-util-is-body-ok-link` in `rehype-minify`.
isBodyOkLink(value) ||
(meta(value) && hasProperty(value, 'itemProp')))
value.type === 'text' ||
basic(value) ||
embedded(value) ||
// @ts-expect-error: To do: update `hast-util-is-body-ok-link` in `rehype-minify`.
isBodyOkLink(value) ||
(meta(value) && hasProperty(value, 'itemProp'))
)
}

/**
* @param {unknown} value
* @returns {value is Nodes}
*/
function node(value) {
// @ts-expect-error: looks like an object.
return value && typeof value === 'object' && 'type' in value
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Check if the given value is [*phrasing*][spec] content.

###### Parameters

* `value` (`unknown`)
thing to check, typically [`Node`][node]
* `value` ([`Node`][node])
node to check

###### Returns

Expand Down

0 comments on commit 075e725

Please sign in to comment.