@cjser/parse5 0.0.0-stage → 8.1.0-cjser.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ const UNDEFINED_CODE_POINTS = new Set([
2
+ 65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
3
+ 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
4
+ 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574,
5
+ 1048575, 1114110, 1114111,
6
+ ]);
7
+ export const REPLACEMENT_CHARACTER = '\uFFFD';
8
+ export var CODE_POINTS;
9
+ (function (CODE_POINTS) {
10
+ CODE_POINTS[CODE_POINTS["EOF"] = -1] = "EOF";
11
+ CODE_POINTS[CODE_POINTS["NULL"] = 0] = "NULL";
12
+ CODE_POINTS[CODE_POINTS["TABULATION"] = 9] = "TABULATION";
13
+ CODE_POINTS[CODE_POINTS["CARRIAGE_RETURN"] = 13] = "CARRIAGE_RETURN";
14
+ CODE_POINTS[CODE_POINTS["LINE_FEED"] = 10] = "LINE_FEED";
15
+ CODE_POINTS[CODE_POINTS["FORM_FEED"] = 12] = "FORM_FEED";
16
+ CODE_POINTS[CODE_POINTS["SPACE"] = 32] = "SPACE";
17
+ CODE_POINTS[CODE_POINTS["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
18
+ CODE_POINTS[CODE_POINTS["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
19
+ CODE_POINTS[CODE_POINTS["AMPERSAND"] = 38] = "AMPERSAND";
20
+ CODE_POINTS[CODE_POINTS["APOSTROPHE"] = 39] = "APOSTROPHE";
21
+ CODE_POINTS[CODE_POINTS["HYPHEN_MINUS"] = 45] = "HYPHEN_MINUS";
22
+ CODE_POINTS[CODE_POINTS["SOLIDUS"] = 47] = "SOLIDUS";
23
+ CODE_POINTS[CODE_POINTS["DIGIT_0"] = 48] = "DIGIT_0";
24
+ CODE_POINTS[CODE_POINTS["DIGIT_9"] = 57] = "DIGIT_9";
25
+ CODE_POINTS[CODE_POINTS["SEMICOLON"] = 59] = "SEMICOLON";
26
+ CODE_POINTS[CODE_POINTS["LESS_THAN_SIGN"] = 60] = "LESS_THAN_SIGN";
27
+ CODE_POINTS[CODE_POINTS["EQUALS_SIGN"] = 61] = "EQUALS_SIGN";
28
+ CODE_POINTS[CODE_POINTS["GREATER_THAN_SIGN"] = 62] = "GREATER_THAN_SIGN";
29
+ CODE_POINTS[CODE_POINTS["QUESTION_MARK"] = 63] = "QUESTION_MARK";
30
+ CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_A"] = 65] = "LATIN_CAPITAL_A";
31
+ CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_Z"] = 90] = "LATIN_CAPITAL_Z";
32
+ CODE_POINTS[CODE_POINTS["RIGHT_SQUARE_BRACKET"] = 93] = "RIGHT_SQUARE_BRACKET";
33
+ CODE_POINTS[CODE_POINTS["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
34
+ CODE_POINTS[CODE_POINTS["LATIN_SMALL_A"] = 97] = "LATIN_SMALL_A";
35
+ CODE_POINTS[CODE_POINTS["LATIN_SMALL_Z"] = 122] = "LATIN_SMALL_Z";
36
+ })(CODE_POINTS || (CODE_POINTS = {}));
37
+ export const SEQUENCES = {
38
+ DASH_DASH: '--',
39
+ CDATA_START: '[CDATA[',
40
+ DOCTYPE: 'doctype',
41
+ SCRIPT: 'script',
42
+ PUBLIC: 'public',
43
+ SYSTEM: 'system',
44
+ };
45
+ //Surrogates
46
+ export function isSurrogate(cp) {
47
+ return cp >= 55296 && cp <= 57343;
48
+ }
49
+ export function isSurrogatePair(cp) {
50
+ return cp >= 56320 && cp <= 57343;
51
+ }
52
+ export function getSurrogatePairCodePoint(cp1, cp2) {
53
+ return (cp1 - 55296) * 1024 + 9216 + cp2;
54
+ }
55
+ //NOTE: excluding NULL and ASCII whitespace
56
+ export function isControlCodePoint(cp) {
57
+ return ((cp !== 0x20 && cp !== 0x0a && cp !== 0x0d && cp !== 0x09 && cp !== 0x0c && cp >= 0x01 && cp <= 0x1f) ||
58
+ (cp >= 0x7f && cp <= 0x9f));
59
+ }
60
+ export function isUndefinedCodePoint(cp) {
61
+ return (cp >= 64976 && cp <= 65007) || UNDEFINED_CODE_POINTS.has(cp);
62
+ }
@@ -0,0 +1,71 @@
1
+ import { type ParserOptions } from './parser/index.js';
2
+ import type { DefaultTreeAdapterMap } from './tree-adapters/default.js';
3
+ import type { TreeAdapterTypeMap } from './tree-adapters/interface.js';
4
+ export { type DefaultTreeAdapterMap, defaultTreeAdapter } from './tree-adapters/default.js';
5
+ import type * as DefaultTreeAdapter from './tree-adapters/default.js';
6
+ export declare namespace DefaultTreeAdapterTypes {
7
+ type Document = DefaultTreeAdapter.Document;
8
+ type DocumentFragment = DefaultTreeAdapter.DocumentFragment;
9
+ type Element = DefaultTreeAdapter.Element;
10
+ type CommentNode = DefaultTreeAdapter.CommentNode;
11
+ type TextNode = DefaultTreeAdapter.TextNode;
12
+ type Template = DefaultTreeAdapter.Template;
13
+ type DocumentType = DefaultTreeAdapter.DocumentType;
14
+ type ParentNode = DefaultTreeAdapter.ParentNode;
15
+ type ChildNode = DefaultTreeAdapter.ChildNode;
16
+ type Node = DefaultTreeAdapter.Node;
17
+ type DefaultTreeAdapterMap = DefaultTreeAdapter.DefaultTreeAdapterMap;
18
+ }
19
+ export type { ElementCreationContext, TreeAdapter, TreeAdapterTypeMap } from './tree-adapters/interface.js';
20
+ export { type ParserOptions, /** @internal */ Parser, InsertionMode } from './parser/index.js';
21
+ export { serialize, serializeOuter, type SerializerOptions } from './serializer/index.js';
22
+ export { ERR as ErrorCodes, type ParserError, type ParserErrorHandler } from './common/error-codes.js';
23
+ /** @internal */
24
+ export * as foreignContent from './common/foreign-content.js';
25
+ export * as html from './common/html.js';
26
+ export * as Token from './common/token.js';
27
+ /** @internal */
28
+ export { Tokenizer, type TokenizerOptions, TokenizerMode, type TokenHandler } from './tokenizer/index.js';
29
+ /**
30
+ * Parses an HTML string.
31
+ *
32
+ * @param html Input HTML string.
33
+ * @param options Parsing options.
34
+ * @returns Document
35
+ *
36
+ * @example
37
+ *
38
+ * ```js
39
+ * const parse5 = require('@cjser/parse5');
40
+ *
41
+ * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
42
+ *
43
+ * console.log(document.childNodes[1].tagName); //> 'html'
44
+ *```
45
+ */
46
+ export declare function parse<T extends TreeAdapterTypeMap = DefaultTreeAdapterMap>(html: string, options?: ParserOptions<T>): T['document'];
47
+ /**
48
+ * Parses an HTML fragment.
49
+ *
50
+ * @example
51
+ *
52
+ * ```js
53
+ * const parse5 = require('@cjser/parse5');
54
+ *
55
+ * const documentFragment = parse5.parseFragment('<table></table>');
56
+ *
57
+ * console.log(documentFragment.childNodes[0].tagName); //> 'table'
58
+ *
59
+ * // Parses the html fragment in the context of the parsed <table> element.
60
+ * const trFragment = parse5.parseFragment(documentFragment.childNodes[0], '<tr><td>Shake it, baby</td></tr>');
61
+ *
62
+ * console.log(trFragment.childNodes[0].childNodes[0].tagName); //> 'td'
63
+ * ```
64
+ *
65
+ * @param fragmentContext Parsing context element. If specified, given fragment will be parsed as if it was set to the context element's `innerHTML` property.
66
+ * @param html Input HTML fragment string.
67
+ * @param options Parsing options.
68
+ * @returns DocumentFragment
69
+ */
70
+ export declare function parseFragment<T extends TreeAdapterTypeMap = DefaultTreeAdapterMap>(fragmentContext: T['parentNode'] | null, html: string, options: ParserOptions<T>): T['documentFragment'];
71
+ export declare function parseFragment<T extends TreeAdapterTypeMap = DefaultTreeAdapterMap>(html: string, options?: ParserOptions<T>): T['documentFragment'];
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import { Parser } from './parser/index.js';
2
+ export { defaultTreeAdapter } from './tree-adapters/default.js';
3
+ export { /** @internal */ Parser, InsertionMode } from './parser/index.js';
4
+ export { serialize, serializeOuter } from './serializer/index.js';
5
+ export { ERR as ErrorCodes } from './common/error-codes.js';
6
+ /** @internal */
7
+ export * as foreignContent from './common/foreign-content.js';
8
+ export * as html from './common/html.js';
9
+ export * as Token from './common/token.js';
10
+ /** @internal */
11
+ export { Tokenizer, TokenizerMode } from './tokenizer/index.js';
12
+ // Shorthands
13
+ /**
14
+ * Parses an HTML string.
15
+ *
16
+ * @param html Input HTML string.
17
+ * @param options Parsing options.
18
+ * @returns Document
19
+ *
20
+ * @example
21
+ *
22
+ * ```js
23
+ * const parse5 = require('@cjser/parse5');
24
+ *
25
+ * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
26
+ *
27
+ * console.log(document.childNodes[1].tagName); //> 'html'
28
+ *```
29
+ */
30
+ export function parse(html, options) {
31
+ return Parser.parse(html, options);
32
+ }
33
+ export function parseFragment(fragmentContext, html, options) {
34
+ if (typeof fragmentContext === 'string') {
35
+ options = html;
36
+ html = fragmentContext;
37
+ fragmentContext = null;
38
+ }
39
+ const parser = Parser.getFragmentParser(fragmentContext, options);
40
+ parser.tokenizer.write(html, true);
41
+ return parser.getFragment();
42
+ }
@@ -0,0 +1,36 @@
1
+ import type { TagToken } from '../common/token.js';
2
+ import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js';
3
+ export declare enum EntryType {
4
+ Marker = 0,
5
+ Element = 1
6
+ }
7
+ interface MarkerEntry {
8
+ type: EntryType.Marker;
9
+ }
10
+ export interface ElementEntry<T extends TreeAdapterTypeMap> {
11
+ type: EntryType.Element;
12
+ element: T['element'];
13
+ token: TagToken;
14
+ }
15
+ export type Entry<T extends TreeAdapterTypeMap> = MarkerEntry | ElementEntry<T>;
16
+ export declare class FormattingElementList<T extends TreeAdapterTypeMap> {
17
+ private treeAdapter;
18
+ entries: Entry<T>[];
19
+ bookmark: Entry<T> | null;
20
+ constructor(treeAdapter: TreeAdapter<T>);
21
+ private _getNoahArkConditionCandidates;
22
+ private _ensureNoahArkCondition;
23
+ insertMarker(): void;
24
+ pushElement(element: T['element'], token: TagToken): void;
25
+ insertElementAfterBookmark(element: T['element'], token: TagToken): void;
26
+ removeEntry(entry: Entry<T>): void;
27
+ /**
28
+ * Clears the list of formatting elements up to the last marker.
29
+ *
30
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
31
+ */
32
+ clearToLastMarker(): void;
33
+ getElementEntryInScopeWithTagName(tagName: string): ElementEntry<T> | null;
34
+ getElementEntry(element: T['element']): ElementEntry<T> | undefined;
35
+ }
36
+ export {};
@@ -0,0 +1,110 @@
1
+ //Const
2
+ const NOAH_ARK_CAPACITY = 3;
3
+ export var EntryType;
4
+ (function (EntryType) {
5
+ EntryType[EntryType["Marker"] = 0] = "Marker";
6
+ EntryType[EntryType["Element"] = 1] = "Element";
7
+ })(EntryType || (EntryType = {}));
8
+ const MARKER = { type: EntryType.Marker };
9
+ //List of formatting elements
10
+ export class FormattingElementList {
11
+ constructor(treeAdapter) {
12
+ this.treeAdapter = treeAdapter;
13
+ this.entries = [];
14
+ this.bookmark = null;
15
+ }
16
+ //Noah Ark's condition
17
+ //OPTIMIZATION: at first we try to find possible candidates for exclusion using
18
+ //lightweight heuristics without thorough attributes check.
19
+ _getNoahArkConditionCandidates(newElement, neAttrs) {
20
+ const candidates = [];
21
+ const neAttrsLength = neAttrs.length;
22
+ const neTagName = this.treeAdapter.getTagName(newElement);
23
+ const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
24
+ for (let i = 0; i < this.entries.length; i++) {
25
+ const entry = this.entries[i];
26
+ if (entry.type === EntryType.Marker) {
27
+ break;
28
+ }
29
+ const { element } = entry;
30
+ if (this.treeAdapter.getTagName(element) === neTagName &&
31
+ this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
32
+ const elementAttrs = this.treeAdapter.getAttrList(element);
33
+ if (elementAttrs.length === neAttrsLength) {
34
+ candidates.push({ idx: i, attrs: elementAttrs });
35
+ }
36
+ }
37
+ }
38
+ return candidates;
39
+ }
40
+ _ensureNoahArkCondition(newElement) {
41
+ if (this.entries.length < NOAH_ARK_CAPACITY)
42
+ return;
43
+ const neAttrs = this.treeAdapter.getAttrList(newElement);
44
+ const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
45
+ if (candidates.length < NOAH_ARK_CAPACITY)
46
+ return;
47
+ //NOTE: build attrs map for the new element, so we can perform fast lookups
48
+ const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
49
+ let validCandidates = 0;
50
+ //NOTE: remove bottommost candidates, until Noah's Ark condition will not be met
51
+ for (let i = 0; i < candidates.length; i++) {
52
+ const candidate = candidates[i];
53
+ // We know that `candidate.attrs.length === neAttrs.length`
54
+ if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
55
+ validCandidates += 1;
56
+ if (validCandidates >= NOAH_ARK_CAPACITY) {
57
+ this.entries.splice(candidate.idx, 1);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ //Mutations
63
+ insertMarker() {
64
+ this.entries.unshift(MARKER);
65
+ }
66
+ pushElement(element, token) {
67
+ this._ensureNoahArkCondition(element);
68
+ this.entries.unshift({
69
+ type: EntryType.Element,
70
+ element,
71
+ token,
72
+ });
73
+ }
74
+ insertElementAfterBookmark(element, token) {
75
+ const bookmarkIdx = this.entries.indexOf(this.bookmark);
76
+ this.entries.splice(bookmarkIdx, 0, {
77
+ type: EntryType.Element,
78
+ element,
79
+ token,
80
+ });
81
+ }
82
+ removeEntry(entry) {
83
+ const entryIndex = this.entries.indexOf(entry);
84
+ if (entryIndex !== -1) {
85
+ this.entries.splice(entryIndex, 1);
86
+ }
87
+ }
88
+ /**
89
+ * Clears the list of formatting elements up to the last marker.
90
+ *
91
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
92
+ */
93
+ clearToLastMarker() {
94
+ const markerIdx = this.entries.indexOf(MARKER);
95
+ if (markerIdx === -1) {
96
+ this.entries.length = 0;
97
+ }
98
+ else {
99
+ this.entries.splice(0, markerIdx + 1);
100
+ }
101
+ }
102
+ //Search
103
+ getElementEntryInScopeWithTagName(tagName) {
104
+ const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);
105
+ return entry && entry.type === EntryType.Element ? entry : null;
106
+ }
107
+ getElementEntry(element) {
108
+ return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
109
+ }
110
+ }
@@ -0,0 +1,226 @@
1
+ import { Tokenizer, TokenizerMode, type TokenHandler } from '../tokenizer/index.js';
2
+ import { OpenElementStack, type StackHandler } from './open-element-stack.js';
3
+ import { FormattingElementList } from './formatting-element-list.js';
4
+ import { ERR, type ParserErrorHandler } from '../common/error-codes.js';
5
+ import { TAG_ID as $, NS } from '../common/html.js';
6
+ import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js';
7
+ import { type Token, type CommentToken, type CharacterToken, type TagToken, type DoctypeToken, type EOFToken, type LocationWithAttributes, type Attribute } from '../common/token.js';
8
+ export declare enum InsertionMode {
9
+ INITIAL = 0,
10
+ BEFORE_HTML = 1,
11
+ BEFORE_HEAD = 2,
12
+ IN_HEAD = 3,
13
+ IN_HEAD_NO_SCRIPT = 4,
14
+ AFTER_HEAD = 5,
15
+ IN_BODY = 6,
16
+ TEXT = 7,
17
+ IN_TABLE = 8,
18
+ IN_TABLE_TEXT = 9,
19
+ IN_CAPTION = 10,
20
+ IN_COLUMN_GROUP = 11,
21
+ IN_TABLE_BODY = 12,
22
+ IN_ROW = 13,
23
+ IN_CELL = 14,
24
+ IN_SELECT = 15,
25
+ IN_SELECT_IN_TABLE = 16,
26
+ IN_TEMPLATE = 17,
27
+ AFTER_BODY = 18,
28
+ IN_FRAMESET = 19,
29
+ AFTER_FRAMESET = 20,
30
+ AFTER_AFTER_BODY = 21,
31
+ AFTER_AFTER_FRAMESET = 22
32
+ }
33
+ interface InsertionLocation<T extends TreeAdapterTypeMap> {
34
+ parent: T['parentNode'];
35
+ beforeElement: T['element'] | null;
36
+ }
37
+ export interface ParserOptions<T extends TreeAdapterTypeMap> {
38
+ /**
39
+ * The [scripting flag](https://html.spec.whatwg.org/multipage/parsing.html#scripting-flag). If set
40
+ * to `true`, `noscript` element content will be parsed as text.
41
+ *
42
+ * @default `true`
43
+ */
44
+ scriptingEnabled?: boolean;
45
+ /**
46
+ * Enables source code location information. When enabled, each node (except the root node)
47
+ * will have a `sourceCodeLocation` property. If the node is not an empty element, `sourceCodeLocation` will
48
+ * be a {@link ElementLocation} object, otherwise it will be {@link Location}.
49
+ * If the element was implicitly created by the parser (as part of
50
+ * [tree correction](https://html.spec.whatwg.org/multipage/syntax.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser)),
51
+ * its `sourceCodeLocation` property will be `undefined`.
52
+ *
53
+ * @default `false`
54
+ */
55
+ sourceCodeLocationInfo?: boolean;
56
+ /**
57
+ * Specifies the resulting tree format.
58
+ *
59
+ * @default `treeAdapters.default`
60
+ */
61
+ treeAdapter?: TreeAdapter<T>;
62
+ /**
63
+ * Callback for parse errors.
64
+ *
65
+ * @default `null`
66
+ */
67
+ onParseError?: ParserErrorHandler | null;
68
+ }
69
+ export declare class Parser<T extends TreeAdapterTypeMap> implements TokenHandler, StackHandler<T> {
70
+ /** @internal */
71
+ fragmentContext: T['element'] | null;
72
+ /** @internal */
73
+ scriptHandler: null | ((pendingScript: T['element']) => void);
74
+ treeAdapter: TreeAdapter<T>;
75
+ /** @internal */
76
+ onParseError: ParserErrorHandler | null;
77
+ protected currentToken: Token | null;
78
+ options: Required<ParserOptions<T>>;
79
+ document: T['document'];
80
+ constructor(options?: ParserOptions<T>, document?: T['document'],
81
+ /** @internal */
82
+ fragmentContext?: T['element'] | null,
83
+ /** @internal */
84
+ scriptHandler?: null | ((pendingScript: T['element']) => void));
85
+ static parse<T extends TreeAdapterTypeMap>(html: string, options?: ParserOptions<T>): T['document'];
86
+ static getFragmentParser<T extends TreeAdapterTypeMap>(fragmentContext?: T['parentNode'] | null, options?: ParserOptions<T>): Parser<T>;
87
+ getFragment(): T['documentFragment'];
88
+ tokenizer: Tokenizer;
89
+ stopped: boolean;
90
+ /** @internal */
91
+ insertionMode: InsertionMode;
92
+ /** @internal */
93
+ originalInsertionMode: InsertionMode;
94
+ /** @internal */
95
+ fragmentContextID: $;
96
+ /** @internal */
97
+ headElement: null | T['element'];
98
+ /** @internal */
99
+ formElement: null | T['element'];
100
+ /** @internal */
101
+ openElements: OpenElementStack<T>;
102
+ /** @internal */
103
+ activeFormattingElements: FormattingElementList<T>;
104
+ /** Indicates that the current node is not an element in the HTML namespace */
105
+ protected currentNotInHTML: boolean;
106
+ /**
107
+ * The template insertion mode stack is maintained from the left.
108
+ * Ie. the topmost element will always have index 0.
109
+ *
110
+ * @internal
111
+ */
112
+ tmplInsertionModeStack: InsertionMode[];
113
+ /** @internal */
114
+ pendingCharacterTokens: CharacterToken[];
115
+ /** @internal */
116
+ hasNonWhitespacePendingCharacterToken: boolean;
117
+ /** @internal */
118
+ framesetOk: boolean;
119
+ /** @internal */
120
+ skipNextNewLine: boolean;
121
+ /** @internal */
122
+ fosterParentingEnabled: boolean;
123
+ /** @internal */
124
+ _err(token: Token, code: ERR, beforeToken?: boolean): void;
125
+ /** @internal */
126
+ onItemPush(node: T['parentNode'], tid: number, isTop: boolean): void;
127
+ /** @internal */
128
+ onItemPop(node: T['parentNode'], isTop: boolean): void;
129
+ protected _setContextModes(current: T['parentNode'] | undefined, tid: number | undefined): void;
130
+ /** @protected */
131
+ _switchToTextParsing(currentToken: TagToken, nextTokenizerState: (typeof TokenizerMode)[keyof typeof TokenizerMode]): void;
132
+ switchToPlaintextParsing(): void;
133
+ /** @protected */
134
+ _getAdjustedCurrentElement(): T['element'];
135
+ /** @protected */
136
+ _findFormInFragmentContext(): void;
137
+ protected _initTokenizerForFragmentParsing(): void;
138
+ /** @protected */
139
+ _setDocumentType(token: DoctypeToken): void;
140
+ /** @protected */
141
+ _attachElementToTree(element: T['element'], location: LocationWithAttributes | null, insertionLocation: InsertionLocation<T>): void;
142
+ /** @protected */
143
+ _getInsertionLocation(): InsertionLocation<T>;
144
+ /** @protected */
145
+ _createElement(tagName: string, namespaceURI: NS, attrs: Attribute[], intendedParent: T['parentNode']): T['element'];
146
+ /**
147
+ * For self-closing tags. Add an element to the tree, but skip adding it
148
+ * to the stack.
149
+ */
150
+ /** @protected */
151
+ _appendElement(token: TagToken, namespaceURI: NS): void;
152
+ /** @protected */
153
+ _insertElement(token: TagToken, namespaceURI: NS): void;
154
+ /** @protected */
155
+ _insertFakeElement(tagName: string, tagID: $): void;
156
+ /** @protected */
157
+ _insertTemplate(token: TagToken): void;
158
+ /** @protected */
159
+ _insertFakeRootElement(): void;
160
+ /** @protected */
161
+ _appendCommentNode(token: CommentToken, parent: T['parentNode']): void;
162
+ /** @protected */
163
+ _insertCharacters(token: CharacterToken): void;
164
+ /** @protected */
165
+ _adoptNodes(donor: T['parentNode'], recipient: T['parentNode']): void;
166
+ /** @protected */
167
+ _setEndLocation(element: T['element'], closingToken: Token): void;
168
+ protected shouldProcessStartTagTokenInForeignContent(token: TagToken): boolean;
169
+ /** @protected */
170
+ _processToken(token: Token): void;
171
+ /** @protected */
172
+ _isIntegrationPoint(tid: $, element: T['element'], foreignNS?: NS): boolean;
173
+ /** @protected */
174
+ _reconstructActiveFormattingElements(): void;
175
+ /** @protected */
176
+ _closeTableCell(): void;
177
+ /** @protected */
178
+ _closePElement(): void;
179
+ /** @protected */
180
+ _resetInsertionMode(): void;
181
+ /** @protected */
182
+ _resetInsertionModeForSelect(selectIdx: number): void;
183
+ /** @protected */
184
+ _isElementCausesFosterParenting(tn: $): boolean;
185
+ /** @protected */
186
+ _shouldFosterParentOnInsertion(): boolean;
187
+ /** @protected */
188
+ _findFosterParentingLocation(): InsertionLocation<T>;
189
+ /** @protected */
190
+ _fosterParentElement(element: T['element']): void;
191
+ /** @protected */
192
+ _isSpecialElement(element: T['element'], id: $): boolean;
193
+ /** @internal */
194
+ onCharacter(token: CharacterToken): void;
195
+ /** @internal */
196
+ onNullCharacter(token: CharacterToken): void;
197
+ /** @internal */
198
+ onComment(token: CommentToken): void;
199
+ /** @internal */
200
+ onDoctype(token: DoctypeToken): void;
201
+ /** @internal */
202
+ onStartTag(token: TagToken): void;
203
+ /**
204
+ * Processes a given start tag.
205
+ *
206
+ * `onStartTag` checks if a self-closing tag was recognized. When a token
207
+ * is moved inbetween multiple insertion modes, this check for self-closing
208
+ * could lead to false positives. To avoid this, `_processStartTag` is used
209
+ * for nested calls.
210
+ *
211
+ * @param token The token to process.
212
+ * @protected
213
+ */
214
+ _processStartTag(token: TagToken): void;
215
+ /** @protected */
216
+ _startTagOutsideForeignContent(token: TagToken): void;
217
+ /** @internal */
218
+ onEndTag(token: TagToken): void;
219
+ /** @protected */
220
+ _endTagOutsideForeignContent(token: TagToken): void;
221
+ /** @internal */
222
+ onEof(token: EOFToken): void;
223
+ /** @internal */
224
+ onWhitespaceCharacter(token: CharacterToken): void;
225
+ }
226
+ export {};