MCPcopy
hub / github.com/KaTeX/KaTeX / SvgNode

Class SvgNode

src/domTree.ts:497–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495 * SVG nodes are used to render stretchy wide elements.
496 */
497export class SvgNode implements VirtualNode {
498 children: SvgChildNode[];
499 attributes: Record<string, string>;
500
501 constructor(
502 children?: SvgChildNode[],
503 attributes?: Record<string, string>,
504 ) {
505 this.children = children || [];
506 this.attributes = attributes || {};
507 }
508
509 toNode(): Node {
510 const svgNS = "http://www.w3.org/2000/svg";
511 const node = document.createElementNS(svgNS, "svg");
512
513 // Apply attributes
514 for (const attr of Object.keys(this.attributes)) {
515 node.setAttribute(attr, this.attributes[attr]);
516 }
517
518 for (let i = 0; i < this.children.length; i++) {
519 node.appendChild(this.children[i].toNode());
520 }
521 return node;
522 }
523
524 toMarkup(): string {
525 let markup = `<svg xmlns="http://www.w3.org/2000/svg"`;
526
527 // Apply attributes
528 for (const attr of Object.keys(this.attributes)) {
529 markup += ` ${attr}="${escape(this.attributes[attr])}"`;
530 }
531
532 markup += ">";
533
534 for (let i = 0; i < this.children.length; i++) {
535 markup += this.children[i].toMarkup();
536 }
537
538 markup += "</svg>";
539
540 return markup;
541
542 }
543}
544
545export class PathNode implements VirtualNode {
546 pathName: string;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…