data(node, key, val) {
			if (!node?.getAttribute)
				return null;

			let id = node.getAttribute('data-idref');

			/* clear all data */
			if (arguments.length > 1 && key == null) {
				if (id != null) {
					node.removeAttribute('data-idref');
					val = this.registry[id]
					delete this.registry[id];
					return val;
				}

				return null;
			}

			/* clear a key */
			else if (arguments.length > 2 && key != null && val == null) {
				if (id != null) {
					val = this.registry[id][key];
					delete this.registry[id][key];
					return val;
				}

				return null;
			}

			/* set a key */
			else if (arguments.length > 2 && key != null && val != null) {
				if (id == null) {
					do { id = Math.floor(Math.random() * 0xffffffff).toString(16) }
					while (this.registry.hasOwnProperty(id));

					node.setAttribute('data-idref', id);
					this.registry[id] = {};
				}

				return (this.registry[id][key] = val);
			}

			/* get all data */
			else if (arguments.length == 1) {
				if (id != null)
					return this.registry[id];

				return null;
			}

			/* get a key */
			else if (arguments.length == 2) {
				if (id != null)
					return this.registry[id][key];
			}

			return null;
		}
Attaches or detaches arbitrary data to and from a DOM `Node`.

This function is useful to attach non-string values or runtime
data that is not serializable to DOM nodes. To decouple data
from the DOM, values are not added directly to nodes, but
inserted into a registry instead which is then referenced by a
string key stored as `data-idref` attribute in the node.

This function has multiple signatures and is sensitive to the
number of arguments passed to it.

 - `dom.data(node)` -
	 Fetches all data associated with the given node.
 - `dom.data(node, key)` -
	 Fetches a specific key associated with the given node.
 - `dom.data(node, key, val)` -
	 Sets a specific key to the given value associated with the
	 given node.
 - `dom.data(node, null)` -
	 Clears any data associated with the node.
 - `dom.data(node, key, null)` -
	 Clears the given key associated with the node.

@instance
@memberof LuCI.dom
@param {Node} node
The DOM `Node` instance to set or retrieve the data for.

@param {string|null} [key]
This is either a string specifying the key to retrieve, or
`null` to unset the entire node data.

@param {*|null} [val]
This is either a non-`null` value to set for a given key or
`null` to remove the given `key` from the specified node.

@returns {*}
Returns the get or set value, or `null` when no value could
be found.