Skip to main content

TNodeDescriptor

reexport
interface TNodeDescriptor {
  attributes: Record<string, string>;
  classes: Array<string>;
  domNode: null | Element;
  id: null | string;
  markers: Readonly<Markers>;
  tagName: null | string;
  hasClass: (className: string) => boolean;
}

A minimal TNode shape accessible at instantiation.

Fields#

attributes#

required
attributes: Record<string, string>;

Attributes for this tag.

classes#

required
classes: Array<string>;

A list of classes for this node, extracted from the class attribute of the underlying ​Node.

domNode#

required
domNode: null | Element;

A reference to the underlying DOM node.

id#

required
id: null | string;

The id for this node, extracted from the id attribute of the underlying ​Node.

markers#

required
markers: Readonly<Markers>;

Markers form an abstraction in which one node provides semantic information to itself and all its descendants. For example, ins elements, which stand for "insertion" of content in the context of an edit will provide the { edits: 'ins' } marker to all its descendants.

Remarks

This attribute must be considered immutable. Never try to change it by hand, or you might update the markers of an anscestor! For performance reasons, markers instances might be shared from parent to children when they are equal.

tagName#

required
tagName: null | string;

The tag name for this node.

Remarks

Anonymous nodes generated during hoisting won't have a tag name. Also, some TText nodes don't have a tagName.

Methods#

hasClass#

required
hasClass: (className: string) => boolean;

Check if this ​TNode has the given className.

Parameters#

className

The class to check.