Documentation/HtmlDocument
classWORKER

HtmlDocument

js/foo_uie_jsplitter.js:7620

Object returned by utils.ParseHtml

Lightweight DOM-like HTML document backed by the native HTML parser.

Notes:
- This is not a full browser DOM.
- Scripts, CSS, layout, external resources and browser events are not processed.
- innerText is currently an alias of textContent.

propertyWORKERreadonly

body

js/foo_uie_jsplitter.js:7674
body: ?HtmlNode

The document <body> element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello</p></body></html>");
if (doc && doc.body) console.log(doc.body.innerHTML); // "<p>Hello</p>"
propertyWORKERreadonly

documentElement

js/foo_uie_jsplitter.js:7648
documentElement: ?HtmlNode

Root document element, usually the <html> element.

Example

let doc = utils.ParseHtml("<html><body>Hello</body></html>");
if (doc) console.log(doc.documentElement.tagName); // "html"
propertyWORKERreadonly

innerHTML

js/foo_uie_jsplitter.js:7712
innerHTML: string

Serialized HTML markup inside the document body.
If the document has no body, this falls back to the root element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello <b>world</b></p></body></html>");
if (doc) console.log(doc.innerHTML); // "<p>Hello <b>world</b></p>"
propertyWORKERreadonly

innerText

js/foo_uie_jsplitter.js:7702
innerText: string

Alias of textContent.
Since this parser has no browser layout engine, innerText does not emulate CSS visibility, rendered line wrapping, or layout-dependent text extraction.

propertyWORKERreadonly

outerHTML

js/foo_uie_jsplitter.js:7726
outerHTML: string

Serialized outer HTML of the root element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello</p></body></html>");
if (doc) console.log(doc.outerHTML); // "<html><head></head><body><p>Hello</p></body></html>"
propertyWORKERreadonly

root

js/foo_uie_jsplitter.js:7634
root: ?HtmlNode

Root document element, usually the <html> element.
Alias of documentElement.

Example

let doc = utils.ParseHtml("<html><body>Hello</body></html>");
if (doc) console.log(doc.root.tagName); // "html"
propertyWORKERreadonly

textContent

js/foo_uie_jsplitter.js:7687
textContent: string

Text content of the document body.
If the document has no body, this falls back to the root element text.
Whitespace is returned as it exists in the parsed text nodes.

Example

let doc = utils.ParseHtml("<html><body><p>Hello <b>world</b></p></body></html>");
if (doc) console.log(doc.textContent); // "Hello world"
methodWORKER

getElementsByTagName

js/foo_uie_jsplitter.js:7770
getElementsByTagName(tagName)

Returns all descendant elements with the specified tag name.
Use "*" to return all descendant elements.

Parameters

NameTypeDescription
tagNamestring

Tag name, for example "a", "div", "section" or "*".

Returns

Array<HtmlNode> —

Array of matching nodes. Empty array if nothing matches.

Example

const doc = utils.ParseHtml("<p><a href='https://example.com'>Link</a></p>");
const links = doc ? doc.getElementsByTagName("a") : [];
console.log(links.length); // 1
methodWORKER

querySelector

js/foo_uie_jsplitter.js:7739
querySelector(selector)

Returns the first element matching a CSS selector.

Parameters

NameTypeDescription
selectorstring

CSS selector.

Returns

?HtmlNode —

First matching node, or null if nothing matches.

Example

let doc = utils.ParseHtml("<html><body><p class='name'>Test Artist</p></body></html>");
let node = doc ? doc.querySelector(".name") : null;
if (node) console.log(node.textContent); // "Test Artist"
methodWORKER

querySelectorAll

js/foo_uie_jsplitter.js:7754
querySelectorAll(selector)

Returns all elements matching a CSS selector.
The returned value is a regular JavaScript array.

Parameters

NameTypeDescription
selectorstring

CSS selector.

Returns

Array<HtmlNode> —

Array of matching nodes. Empty array if nothing matches.

Example

let doc = utils.ParseHtml("<ul><li class='album'>A</li><li class='album'>B</li></ul>");
let albums = doc ? doc.querySelectorAll(".album") : [];
console.log(albums.length); // 2