content

Helpers for working with element content

API

isSubstantiveElement(node) static method

Return true if the given node is likely to be useful as component content.

This will be true for nodes that are: a) instances of Element (HTMLElement or SVGElement), and b) not on a blacklist of normally invisible elements (such as style or script). Among other things, this returns false for Text nodes.

This is used by ContentItemsMixin to filter out nodes which are unlikely to be interesting as list items. This is intended to satisfy the Gold Standard checklist criteria Auxiliary Content, so that a component does not inadvertently treat <style> and other invisible items as element content.

Parameters:

  • node: Node

Returns: boolean

substantiveElements(nodes) static method

Return a set of Elements which are likely to be useful as component content.

Given a NodeList or array of objects, this will return only those array members that are: a) instances of Element (HTMLElement or SVGElement), and b) not on a blacklist of normally invisible elements (such as style or script). Among other things, this filters out Text nodes.

Parameters:

  • nodes: NodeList|Array.the list of nodes to filter

Returns: Array.Array. the filtered elements