MCPcopy Index your code
hub / github.com/fb55/htmlparser2 / emitOpenTag

Method emitOpenTag

src/Parser.ts:402–439  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

400 }
401
402 private emitOpenTag(name: string) {
403 this.openTagStart = this.startIndex;
404 this.tagname = name;
405
406 /*
407 * The spec ignores a second <form> when one is already open.
408 * Setting tagname to "" suppresses all downstream effects: attribs
409 * stays null so endOpenTag is a no-op, and closeCurrentTag can't
410 * match "" on the stack.
411 */
412 if (this.htmlMode && name === "form" && this.stack.includes("form")) {
413 this.tagname = "";
414 return;
415 }
416
417 const impliesClose = this.htmlMode && openImpliesClose.get(name);
418
419 if (impliesClose) {
420 while (this.stack.length > 0 && impliesClose.has(this.stack[0])) {
421 this.popElement(true);
422 }
423 }
424 if (!this.isVoidElement(name)) {
425 this.stack.unshift(name);
426
427 if (this.htmlMode) {
428 if (name === "svg") {
429 this.foreignContext.unshift(ForeignContext.Svg);
430 } else if (name === "math") {
431 this.foreignContext.unshift(ForeignContext.MathML);
432 } else if (htmlIntegrationElements.has(name)) {
433 this.foreignContext.unshift(ForeignContext.None);
434 }
435 }
436 }
437 this.cbs.onopentagname?.(name);
438 if (this.cbs.onopentag) this.attribs = {};
439 }
440
441 private endOpenTag(isImplied: boolean) {
442 this.startIndex = this.openTagStart;

Callers 2

onopentagnameMethod · 0.95
onclosetagMethod · 0.95

Calls 3

popElementMethod · 0.95
isVoidElementMethod · 0.95
onopentagnameMethod · 0.65

Tested by

no test coverage detected