* Trim possible empty head/tail text and comment * nodes inside a parent. * * @param {Node} node
(node)
| 1396 | */ |
| 1397 | |
| 1398 | function trimNode(node) { |
| 1399 | var child; |
| 1400 | /* eslint-disable no-sequences */ |
| 1401 | while ((child = node.firstChild, isTrimmable(child))) { |
| 1402 | node.removeChild(child); |
| 1403 | } |
| 1404 | while ((child = node.lastChild, isTrimmable(child))) { |
| 1405 | node.removeChild(child); |
| 1406 | } |
| 1407 | /* eslint-enable no-sequences */ |
| 1408 | } |
| 1409 | |
| 1410 | function isTrimmable(node) { |
| 1411 | return node && (node.nodeType === 3 && !node.data.trim() || node.nodeType === 8); |
no test coverage detected