Skip to content

clean

clean<T>(node): T

Defined in: core/dom/elements.ts:67

Removes the whitespace-only text nodes inside a node, at every depth.

This changes the node it is given and returns it. Use it to stop the gaps between inline elements, which come from the whitespace in the HTML source.

T extends Node

T

Node to clean, usually an element.

T

The same node.

clean($q('.menu')); // '<ul> <li>a</li> <li>b</li> </ul>' becomes '<ul><li>a</li><li>b</li></ul>'