-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dom: Add types to clean-node-list (#30412)
* dom: Type dependencies of clean-node-list * dom: Add types to clean-node-list * Fix property descriptions
- Loading branch information
1 parent
ea6035f
commit 8be7a8d
Showing
8 changed files
with
71 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { assertIsDefined } from '../utils/assert-is-defined'; | ||
|
||
/** | ||
* Given two DOM nodes, inserts the former in the DOM as the next sibling of | ||
* the latter. | ||
* | ||
* @param {Element} newNode Node to be inserted. | ||
* @param {Element} referenceNode Node after which to perform the insertion. | ||
* @param {Node} newNode Node to be inserted. | ||
* @param {Node} referenceNode Node after which to perform the insertion. | ||
* @return {void} | ||
*/ | ||
export default function insertAfter( newNode, referenceNode ) { | ||
assertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' ); | ||
referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable jsdoc/valid-types */ | ||
/** | ||
* @param {Node | null | undefined} node | ||
* @return {node is Element} True if node is an Element node | ||
*/ | ||
export default function isElement( node ) { | ||
/* eslint-enable jsdoc/valid-types */ | ||
return !! node && node.nodeType === node.ELEMENT_NODE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { assertIsDefined } from '../utils/assert-is-defined'; | ||
|
||
/** | ||
* Given a DOM node, removes it from the DOM. | ||
* | ||
* @param {Element} node Node to be removed. | ||
* @param {Node} node Node to be removed. | ||
* @return {void} | ||
*/ | ||
export default function remove( node ) { | ||
assertIsDefined( node.parentNode, 'node.parentNode' ); | ||
node.parentNode.removeChild( node ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters