API / Minn\Html\Tree / Node

Node final class

Minn\Html\Tree\Node · public/minn/src/Minn/Html/Tree/Node.php · 109 lines

A node the tree builder places: an element (named as the HTML API reports it, upper-cased, with its namespace) or a text, comment, doctype or other leaf. Real when a token in the document made it (its offset is where that token starts), virtual when the parser implied it.

Constants and properties

constVOID = array ( 0 => 'AREA', 1 => 'BASE', 2 => 'BASEFONT', 3 => 'BGSOUND', 4 => 'BR', 5 => 'COL', 6 => 'EMBED', 7 => 'FRAME', 8 => 'HR', 9 => 'IMG', 10 => 'INPUT', 11 => 'KEYGEN', 12 => 'LINK', 13 => 'META', 14 => 'PARAM', 15 => 'SOURCE', 16 => 'TRACK', 17 => 'WBR', )
constATOMIC = array ( 0 => 'SCRIPT', 1 => 'STYLE', 2 => 'TEXTAREA', 3 => 'TITLE', 4 => 'XMP', 5 => 'IFRAME', 6 => 'NOEMBED', 7 => 'NOFRAMES', )

Elements whose body the tokenizer reads whole, so they never take a closer.

privatebool $selfClosing
privatearray $attributes
privatestring $text
propreadonly string $type

Promoted from the constructor.

propreadonly string $name

Promoted from the constructor.

propreadonly string $namespace

Promoted from the constructor.

propreadonly ?int $offset

Promoted from the constructor.

Public

new__construct(string $type, string $name, string $namespace, ?int $offset)#
staticelement(string $name, string $namespace, ?int $offset, array $attributes = array ( )): self#

An element; the attributes kept are the ones the builder compares.

$attributesarray<string, string|true>
staticleaf(string $type, string $name, string $namespace, ?int $offset, string $text): self#

A leaf: text, a comment, a doctype, a CDATA section, a processing instruction.

methodselfClosed(): self#

The same element, marked as written with "/>".

methodisSelfClosing(): bool#

Whether the element was written with "/>".

methodtext(): string#

A leaf's text.

methodattributes(): array#

The attributes kept for comparison.

@return array<string, string|true>
methodisHtml(string ...$names): bool#

Whether this is an HTML element with one of the names.

methodisIn(string $namespace, string ...$names): bool#

Whether this is an element of the namespace with one of the names.

methodexpectsCloser(): bool#

Whether the element is closed by a closer of its own: not a leaf, not void, not read whole, not self-closed foreign content.

methodisHtmlIntegrationPoint(): bool#

Whether this element is an HTML integration point (SVG foreignObject, desc, title; MathML annotation-xml for HTML).

methodisMathTextIntegrationPoint(): bool#

Whether this element is a MathML text integration point.