Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

View file

@ -0,0 +1,37 @@
import type { TagToken } from '../common/token.js';
import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js';
export declare enum EntryType {
Marker = 0,
Element = 1
}
interface MarkerEntry {
type: EntryType.Marker;
}
export interface ElementEntry<T extends TreeAdapterTypeMap> {
type: EntryType.Element;
element: T['element'];
token: TagToken;
}
export type Entry<T extends TreeAdapterTypeMap> = MarkerEntry | ElementEntry<T>;
export declare class FormattingElementList<T extends TreeAdapterTypeMap> {
private treeAdapter;
entries: Entry<T>[];
bookmark: Entry<T> | null;
constructor(treeAdapter: TreeAdapter<T>);
private _getNoahArkConditionCandidates;
private _ensureNoahArkCondition;
insertMarker(): void;
pushElement(element: T['element'], token: TagToken): void;
insertElementAfterBookmark(element: T['element'], token: TagToken): void;
removeEntry(entry: Entry<T>): void;
/**
* Clears the list of formatting elements up to the last marker.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
*/
clearToLastMarker(): void;
getElementEntryInScopeWithTagName(tagName: string): ElementEntry<T> | null;
getElementEntry(element: T['element']): ElementEntry<T> | undefined;
}
export {};
//# sourceMappingURL=formatting-element-list.d.ts.map

View file

@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormattingElementList = exports.EntryType = void 0;
//Const
const NOAH_ARK_CAPACITY = 3;
var EntryType;
(function (EntryType) {
EntryType[EntryType["Marker"] = 0] = "Marker";
EntryType[EntryType["Element"] = 1] = "Element";
})(EntryType = exports.EntryType || (exports.EntryType = {}));
const MARKER = { type: EntryType.Marker };
//List of formatting elements
class FormattingElementList {
constructor(treeAdapter) {
this.treeAdapter = treeAdapter;
this.entries = [];
this.bookmark = null;
}
//Noah Ark's condition
//OPTIMIZATION: at first we try to find possible candidates for exclusion using
//lightweight heuristics without thorough attributes check.
_getNoahArkConditionCandidates(newElement, neAttrs) {
const candidates = [];
const neAttrsLength = neAttrs.length;
const neTagName = this.treeAdapter.getTagName(newElement);
const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
for (let i = 0; i < this.entries.length; i++) {
const entry = this.entries[i];
if (entry.type === EntryType.Marker) {
break;
}
const { element } = entry;
if (this.treeAdapter.getTagName(element) === neTagName &&
this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
const elementAttrs = this.treeAdapter.getAttrList(element);
if (elementAttrs.length === neAttrsLength) {
candidates.push({ idx: i, attrs: elementAttrs });
}
}
}
return candidates;
}
_ensureNoahArkCondition(newElement) {
if (this.entries.length < NOAH_ARK_CAPACITY)
return;
const neAttrs = this.treeAdapter.getAttrList(newElement);
const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
if (candidates.length < NOAH_ARK_CAPACITY)
return;
//NOTE: build attrs map for the new element, so we can perform fast lookups
const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
let validCandidates = 0;
//NOTE: remove bottommost candidates, until Noah's Ark condition will not be met
for (let i = 0; i < candidates.length; i++) {
const candidate = candidates[i];
// We know that `candidate.attrs.length === neAttrs.length`
if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
validCandidates += 1;
if (validCandidates >= NOAH_ARK_CAPACITY) {
this.entries.splice(candidate.idx, 1);
}
}
}
}
//Mutations
insertMarker() {
this.entries.unshift(MARKER);
}
pushElement(element, token) {
this._ensureNoahArkCondition(element);
this.entries.unshift({
type: EntryType.Element,
element,
token,
});
}
insertElementAfterBookmark(element, token) {
const bookmarkIdx = this.entries.indexOf(this.bookmark);
this.entries.splice(bookmarkIdx, 0, {
type: EntryType.Element,
element,
token,
});
}
removeEntry(entry) {
const entryIndex = this.entries.indexOf(entry);
if (entryIndex >= 0) {
this.entries.splice(entryIndex, 1);
}
}
/**
* Clears the list of formatting elements up to the last marker.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
*/
clearToLastMarker() {
const markerIdx = this.entries.indexOf(MARKER);
if (markerIdx >= 0) {
this.entries.splice(0, markerIdx + 1);
}
else {
this.entries.length = 0;
}
}
//Search
getElementEntryInScopeWithTagName(tagName) {
const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);
return entry && entry.type === EntryType.Element ? entry : null;
}
getElementEntry(element) {
return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
}
}
exports.FormattingElementList = FormattingElementList;
//# sourceMappingURL=formatting-element-list.js.map

157
my-app/node_modules/parse5/dist/cjs/parser/index.d.ts generated vendored Executable file
View file

@ -0,0 +1,157 @@
import { Tokenizer, TokenizerMode, type TokenHandler } from '../tokenizer/index.js';
import { OpenElementStack, type StackHandler } from './open-element-stack.js';
import { FormattingElementList } from './formatting-element-list.js';
import { ERR, type ParserErrorHandler } from '../common/error-codes.js';
import { TAG_ID as $, NS } from '../common/html.js';
import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js';
import { type Token, type CommentToken, type CharacterToken, type TagToken, type DoctypeToken, type EOFToken, type LocationWithAttributes } from '../common/token.js';
declare enum InsertionMode {
INITIAL = 0,
BEFORE_HTML = 1,
BEFORE_HEAD = 2,
IN_HEAD = 3,
IN_HEAD_NO_SCRIPT = 4,
AFTER_HEAD = 5,
IN_BODY = 6,
TEXT = 7,
IN_TABLE = 8,
IN_TABLE_TEXT = 9,
IN_CAPTION = 10,
IN_COLUMN_GROUP = 11,
IN_TABLE_BODY = 12,
IN_ROW = 13,
IN_CELL = 14,
IN_SELECT = 15,
IN_SELECT_IN_TABLE = 16,
IN_TEMPLATE = 17,
AFTER_BODY = 18,
IN_FRAMESET = 19,
AFTER_FRAMESET = 20,
AFTER_AFTER_BODY = 21,
AFTER_AFTER_FRAMESET = 22
}
export interface ParserOptions<T extends TreeAdapterTypeMap> {
/**
* The [scripting flag](https://html.spec.whatwg.org/multipage/parsing.html#scripting-flag). If set
* to `true`, `noscript` element content will be parsed as text.
*
* @default `true`
*/
scriptingEnabled?: boolean;
/**
* Enables source code location information. When enabled, each node (except the root node)
* will have a `sourceCodeLocation` property. If the node is not an empty element, `sourceCodeLocation` will
* be a {@link ElementLocation} object, otherwise it will be {@link Location}.
* If the element was implicitly created by the parser (as part of
* [tree correction](https://html.spec.whatwg.org/multipage/syntax.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser)),
* its `sourceCodeLocation` property will be `undefined`.
*
* @default `false`
*/
sourceCodeLocationInfo?: boolean;
/**
* Specifies the resulting tree format.
*
* @default `treeAdapters.default`
*/
treeAdapter?: TreeAdapter<T>;
/**
* Callback for parse errors.
*
* @default `null`
*/
onParseError?: ParserErrorHandler | null;
}
export declare class Parser<T extends TreeAdapterTypeMap> implements TokenHandler, StackHandler<T> {
fragmentContext: T['element'] | null;
scriptHandler: null | ((pendingScript: T['element']) => void);
treeAdapter: TreeAdapter<T>;
onParseError: ParserErrorHandler | null;
private currentToken;
options: Required<ParserOptions<T>>;
document: T['document'];
constructor(options?: ParserOptions<T>, document?: T['document'], fragmentContext?: T['element'] | null, scriptHandler?: null | ((pendingScript: T['element']) => void));
static parse<T extends TreeAdapterTypeMap>(html: string, options?: ParserOptions<T>): T['document'];
static getFragmentParser<T extends TreeAdapterTypeMap>(fragmentContext?: T['parentNode'] | null, options?: ParserOptions<T>): Parser<T>;
getFragment(): T['documentFragment'];
tokenizer: Tokenizer;
stopped: boolean;
insertionMode: InsertionMode;
originalInsertionMode: InsertionMode;
fragmentContextID: $;
headElement: null | T['element'];
formElement: null | T['element'];
openElements: OpenElementStack<T>;
activeFormattingElements: FormattingElementList<T>;
/** Indicates that the current node is not an element in the HTML namespace */
private currentNotInHTML;
/**
* The template insertion mode stack is maintained from the left.
* Ie. the topmost element will always have index 0.
*/
tmplInsertionModeStack: InsertionMode[];
pendingCharacterTokens: CharacterToken[];
hasNonWhitespacePendingCharacterToken: boolean;
framesetOk: boolean;
skipNextNewLine: boolean;
fosterParentingEnabled: boolean;
_err(token: Token, code: ERR, beforeToken?: boolean): void;
onItemPush(node: T['parentNode'], tid: number, isTop: boolean): void;
onItemPop(node: T['parentNode'], isTop: boolean): void;
private _setContextModes;
_switchToTextParsing(currentToken: TagToken, nextTokenizerState: typeof TokenizerMode[keyof typeof TokenizerMode]): void;
switchToPlaintextParsing(): void;
_getAdjustedCurrentElement(): T['element'];
_findFormInFragmentContext(): void;
private _initTokenizerForFragmentParsing;
_setDocumentType(token: DoctypeToken): void;
_attachElementToTree(element: T['element'], location: LocationWithAttributes | null): void;
_appendElement(token: TagToken, namespaceURI: NS): void;
_insertElement(token: TagToken, namespaceURI: NS): void;
_insertFakeElement(tagName: string, tagID: $): void;
_insertTemplate(token: TagToken): void;
_insertFakeRootElement(): void;
_appendCommentNode(token: CommentToken, parent: T['parentNode']): void;
_insertCharacters(token: CharacterToken): void;
_adoptNodes(donor: T['parentNode'], recipient: T['parentNode']): void;
_setEndLocation(element: T['element'], closingToken: Token): void;
private shouldProcessStartTagTokenInForeignContent;
_processToken(token: Token): void;
_isIntegrationPoint(tid: $, element: T['element'], foreignNS?: NS): boolean;
_reconstructActiveFormattingElements(): void;
_closeTableCell(): void;
_closePElement(): void;
_resetInsertionMode(): void;
_resetInsertionModeForSelect(selectIdx: number): void;
_isElementCausesFosterParenting(tn: $): boolean;
_shouldFosterParentOnInsertion(): boolean;
_findFosterParentingLocation(): {
parent: T['parentNode'];
beforeElement: T['element'] | null;
};
_fosterParentElement(element: T['element']): void;
_isSpecialElement(element: T['element'], id: $): boolean;
onCharacter(token: CharacterToken): void;
onNullCharacter(token: CharacterToken): void;
onComment(token: CommentToken): void;
onDoctype(token: DoctypeToken): void;
onStartTag(token: TagToken): void;
/**
* Processes a given start tag.
*
* `onStartTag` checks if a self-closing tag was recognized. When a token
* is moved inbetween multiple insertion modes, this check for self-closing
* could lead to false positives. To avoid this, `_processStartTag` is used
* for nested calls.
*
* @param token The token to process.
*/
_processStartTag(token: TagToken): void;
_startTagOutsideForeignContent(token: TagToken): void;
onEndTag(token: TagToken): void;
_endTagOutsideForeignContent(token: TagToken): void;
onEof(token: EOFToken): void;
onWhitespaceCharacter(token: CharacterToken): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

3163
my-app/node_modules/parse5/dist/cjs/parser/index.js generated vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
import { TAG_ID as $ } from '../common/html.js';
import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js';
export interface StackHandler<T extends TreeAdapterTypeMap> {
onItemPush: (node: T['parentNode'], tid: number, isTop: boolean) => void;
onItemPop: (node: T['parentNode'], isTop: boolean) => void;
}
export declare class OpenElementStack<T extends TreeAdapterTypeMap> {
private treeAdapter;
private handler;
items: T['parentNode'][];
tagIDs: $[];
current: T['parentNode'];
stackTop: number;
tmplCount: number;
currentTagId: $;
get currentTmplContentOrNode(): T['parentNode'];
constructor(document: T['document'], treeAdapter: TreeAdapter<T>, handler: StackHandler<T>);
private _indexOf;
private _isInTemplate;
private _updateCurrentElement;
push(element: T['element'], tagID: $): void;
pop(): void;
replace(oldElement: T['element'], newElement: T['element']): void;
insertAfter(referenceElement: T['element'], newElement: T['element'], newElementID: $): void;
popUntilTagNamePopped(tagName: $): void;
shortenToLength(idx: number): void;
popUntilElementPopped(element: T['element']): void;
private popUntilPopped;
popUntilNumberedHeaderPopped(): void;
popUntilTableCellPopped(): void;
popAllUpToHtmlElement(): void;
private _indexOfTagNames;
private clearBackTo;
clearBackToTableContext(): void;
clearBackToTableBodyContext(): void;
clearBackToTableRowContext(): void;
remove(element: T['element']): void;
tryPeekProperlyNestedBodyElement(): T['element'] | null;
contains(element: T['element']): boolean;
getCommonAncestor(element: T['element']): T['element'] | null;
isRootHtmlElementCurrent(): boolean;
hasInScope(tagName: $): boolean;
hasNumberedHeaderInScope(): boolean;
hasInListItemScope(tagName: $): boolean;
hasInButtonScope(tagName: $): boolean;
hasInTableScope(tagName: $): boolean;
hasTableBodyContextInTableScope(): boolean;
hasInSelectScope(tagName: $): boolean;
generateImpliedEndTags(): void;
generateImpliedEndTagsThoroughly(): void;
generateImpliedEndTagsWithExclusion(exclusionId: $): void;
}
//# sourceMappingURL=open-element-stack.d.ts.map

View file

@ -0,0 +1,316 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenElementStack = void 0;
const html_js_1 = require("../common/html.js");
//Element utils
const IMPLICIT_END_TAG_REQUIRED = new Set([html_js_1.TAG_ID.DD, html_js_1.TAG_ID.DT, html_js_1.TAG_ID.LI, html_js_1.TAG_ID.OPTGROUP, html_js_1.TAG_ID.OPTION, html_js_1.TAG_ID.P, html_js_1.TAG_ID.RB, html_js_1.TAG_ID.RP, html_js_1.TAG_ID.RT, html_js_1.TAG_ID.RTC]);
const IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = new Set([
...IMPLICIT_END_TAG_REQUIRED,
html_js_1.TAG_ID.CAPTION,
html_js_1.TAG_ID.COLGROUP,
html_js_1.TAG_ID.TBODY,
html_js_1.TAG_ID.TD,
html_js_1.TAG_ID.TFOOT,
html_js_1.TAG_ID.TH,
html_js_1.TAG_ID.THEAD,
html_js_1.TAG_ID.TR,
]);
const SCOPING_ELEMENT_NS = new Map([
[html_js_1.TAG_ID.APPLET, html_js_1.NS.HTML],
[html_js_1.TAG_ID.CAPTION, html_js_1.NS.HTML],
[html_js_1.TAG_ID.HTML, html_js_1.NS.HTML],
[html_js_1.TAG_ID.MARQUEE, html_js_1.NS.HTML],
[html_js_1.TAG_ID.OBJECT, html_js_1.NS.HTML],
[html_js_1.TAG_ID.TABLE, html_js_1.NS.HTML],
[html_js_1.TAG_ID.TD, html_js_1.NS.HTML],
[html_js_1.TAG_ID.TEMPLATE, html_js_1.NS.HTML],
[html_js_1.TAG_ID.TH, html_js_1.NS.HTML],
[html_js_1.TAG_ID.ANNOTATION_XML, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.MI, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.MN, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.MO, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.MS, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.MTEXT, html_js_1.NS.MATHML],
[html_js_1.TAG_ID.DESC, html_js_1.NS.SVG],
[html_js_1.TAG_ID.FOREIGN_OBJECT, html_js_1.NS.SVG],
[html_js_1.TAG_ID.TITLE, html_js_1.NS.SVG],
]);
const NAMED_HEADERS = [html_js_1.TAG_ID.H1, html_js_1.TAG_ID.H2, html_js_1.TAG_ID.H3, html_js_1.TAG_ID.H4, html_js_1.TAG_ID.H5, html_js_1.TAG_ID.H6];
const TABLE_ROW_CONTEXT = [html_js_1.TAG_ID.TR, html_js_1.TAG_ID.TEMPLATE, html_js_1.TAG_ID.HTML];
const TABLE_BODY_CONTEXT = [html_js_1.TAG_ID.TBODY, html_js_1.TAG_ID.TFOOT, html_js_1.TAG_ID.THEAD, html_js_1.TAG_ID.TEMPLATE, html_js_1.TAG_ID.HTML];
const TABLE_CONTEXT = [html_js_1.TAG_ID.TABLE, html_js_1.TAG_ID.TEMPLATE, html_js_1.TAG_ID.HTML];
const TABLE_CELLS = [html_js_1.TAG_ID.TD, html_js_1.TAG_ID.TH];
//Stack of open elements
class OpenElementStack {
get currentTmplContentOrNode() {
return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
}
constructor(document, treeAdapter, handler) {
this.treeAdapter = treeAdapter;
this.handler = handler;
this.items = [];
this.tagIDs = [];
this.stackTop = -1;
this.tmplCount = 0;
this.currentTagId = html_js_1.TAG_ID.UNKNOWN;
this.current = document;
}
//Index of element
_indexOf(element) {
return this.items.lastIndexOf(element, this.stackTop);
}
//Update current element
_isInTemplate() {
return this.currentTagId === html_js_1.TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === html_js_1.NS.HTML;
}
_updateCurrentElement() {
this.current = this.items[this.stackTop];
this.currentTagId = this.tagIDs[this.stackTop];
}
//Mutations
push(element, tagID) {
this.stackTop++;
this.items[this.stackTop] = element;
this.current = element;
this.tagIDs[this.stackTop] = tagID;
this.currentTagId = tagID;
if (this._isInTemplate()) {
this.tmplCount++;
}
this.handler.onItemPush(element, tagID, true);
}
pop() {
const popped = this.current;
if (this.tmplCount > 0 && this._isInTemplate()) {
this.tmplCount--;
}
this.stackTop--;
this._updateCurrentElement();
this.handler.onItemPop(popped, true);
}
replace(oldElement, newElement) {
const idx = this._indexOf(oldElement);
this.items[idx] = newElement;
if (idx === this.stackTop) {
this.current = newElement;
}
}
insertAfter(referenceElement, newElement, newElementID) {
const insertionIdx = this._indexOf(referenceElement) + 1;
this.items.splice(insertionIdx, 0, newElement);
this.tagIDs.splice(insertionIdx, 0, newElementID);
this.stackTop++;
if (insertionIdx === this.stackTop) {
this._updateCurrentElement();
}
this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
}
popUntilTagNamePopped(tagName) {
let targetIdx = this.stackTop + 1;
do {
targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
} while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== html_js_1.NS.HTML);
this.shortenToLength(targetIdx < 0 ? 0 : targetIdx);
}
shortenToLength(idx) {
while (this.stackTop >= idx) {
const popped = this.current;
if (this.tmplCount > 0 && this._isInTemplate()) {
this.tmplCount -= 1;
}
this.stackTop--;
this._updateCurrentElement();
this.handler.onItemPop(popped, this.stackTop < idx);
}
}
popUntilElementPopped(element) {
const idx = this._indexOf(element);
this.shortenToLength(idx < 0 ? 0 : idx);
}
popUntilPopped(tagNames, targetNS) {
const idx = this._indexOfTagNames(tagNames, targetNS);
this.shortenToLength(idx < 0 ? 0 : idx);
}
popUntilNumberedHeaderPopped() {
this.popUntilPopped(NAMED_HEADERS, html_js_1.NS.HTML);
}
popUntilTableCellPopped() {
this.popUntilPopped(TABLE_CELLS, html_js_1.NS.HTML);
}
popAllUpToHtmlElement() {
//NOTE: here we assume that the root <html> element is always first in the open element stack, so
//we perform this fast stack clean up.
this.tmplCount = 0;
this.shortenToLength(1);
}
_indexOfTagNames(tagNames, namespace) {
for (let i = this.stackTop; i >= 0; i--) {
if (tagNames.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) {
return i;
}
}
return -1;
}
clearBackTo(tagNames, targetNS) {
const idx = this._indexOfTagNames(tagNames, targetNS);
this.shortenToLength(idx + 1);
}
clearBackToTableContext() {
this.clearBackTo(TABLE_CONTEXT, html_js_1.NS.HTML);
}
clearBackToTableBodyContext() {
this.clearBackTo(TABLE_BODY_CONTEXT, html_js_1.NS.HTML);
}
clearBackToTableRowContext() {
this.clearBackTo(TABLE_ROW_CONTEXT, html_js_1.NS.HTML);
}
remove(element) {
const idx = this._indexOf(element);
if (idx >= 0) {
if (idx === this.stackTop) {
this.pop();
}
else {
this.items.splice(idx, 1);
this.tagIDs.splice(idx, 1);
this.stackTop--;
this._updateCurrentElement();
this.handler.onItemPop(element, false);
}
}
}
//Search
tryPeekProperlyNestedBodyElement() {
//Properly nested <body> element (should be second element in stack).
return this.stackTop >= 1 && this.tagIDs[1] === html_js_1.TAG_ID.BODY ? this.items[1] : null;
}
contains(element) {
return this._indexOf(element) > -1;
}
getCommonAncestor(element) {
const elementIdx = this._indexOf(element) - 1;
return elementIdx >= 0 ? this.items[elementIdx] : null;
}
isRootHtmlElementCurrent() {
return this.stackTop === 0 && this.tagIDs[0] === html_js_1.TAG_ID.HTML;
}
//Element in scope
hasInScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === html_js_1.NS.HTML) {
return true;
}
if (SCOPING_ELEMENT_NS.get(tn) === ns) {
return false;
}
}
return true;
}
hasNumberedHeaderInScope() {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if ((0, html_js_1.isNumberedHeader)(tn) && ns === html_js_1.NS.HTML) {
return true;
}
if (SCOPING_ELEMENT_NS.get(tn) === ns) {
return false;
}
}
return true;
}
hasInListItemScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === html_js_1.NS.HTML) {
return true;
}
if (((tn === html_js_1.TAG_ID.UL || tn === html_js_1.TAG_ID.OL) && ns === html_js_1.NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {
return false;
}
}
return true;
}
hasInButtonScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (tn === tagName && ns === html_js_1.NS.HTML) {
return true;
}
if ((tn === html_js_1.TAG_ID.BUTTON && ns === html_js_1.NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {
return false;
}
}
return true;
}
hasInTableScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== html_js_1.NS.HTML) {
continue;
}
if (tn === tagName) {
return true;
}
if (tn === html_js_1.TAG_ID.TABLE || tn === html_js_1.TAG_ID.TEMPLATE || tn === html_js_1.TAG_ID.HTML) {
return false;
}
}
return true;
}
hasTableBodyContextInTableScope() {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== html_js_1.NS.HTML) {
continue;
}
if (tn === html_js_1.TAG_ID.TBODY || tn === html_js_1.TAG_ID.THEAD || tn === html_js_1.TAG_ID.TFOOT) {
return true;
}
if (tn === html_js_1.TAG_ID.TABLE || tn === html_js_1.TAG_ID.HTML) {
return false;
}
}
return true;
}
hasInSelectScope(tagName) {
for (let i = this.stackTop; i >= 0; i--) {
const tn = this.tagIDs[i];
const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
if (ns !== html_js_1.NS.HTML) {
continue;
}
if (tn === tagName) {
return true;
}
if (tn !== html_js_1.TAG_ID.OPTION && tn !== html_js_1.TAG_ID.OPTGROUP) {
return false;
}
}
return true;
}
//Implied end tags
generateImpliedEndTags() {
while (IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) {
this.pop();
}
}
generateImpliedEndTagsThoroughly() {
while (IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
this.pop();
}
}
generateImpliedEndTagsWithExclusion(exclusionId) {
while (this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
this.pop();
}
}
}
exports.OpenElementStack = OpenElementStack;
//# sourceMappingURL=open-element-stack.js.map