@wordpress/dom
Version:
DOM utilities module for WordPress.
27 lines (25 loc) • 624 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = unwrap;
var _assertIsDefined = require("../utils/assert-is-defined");
/**
* Internal dependencies
*/
/**
* Unwrap the given node. This means any child nodes are moved to the parent.
*
* @param {Node} node The node to unwrap.
*
* @return {void}
*/
function unwrap(node) {
const parent = node.parentNode;
(0, _assertIsDefined.assertIsDefined)(parent, 'node.parentNode');
while (node.firstChild) {
parent.insertBefore(node.firstChild, node);
}
parent.removeChild(node);
}
//# sourceMappingURL=unwrap.js.map
;