MCPcopy
hub / github.com/loggerhead/json4u / toString

Method toString

src/lib/table/tag.ts:67–83  ·  view source on GitHub ↗

* Serializes the element and its children to an HTML string. * All attribute values and text content are properly escaped. * @returns The generated HTML string.

()

Source from the content-addressed store, hash-verified

65 * @returns The generated HTML string.
66 */
67 toString(): string {
68 const childrenStr = this.children
69 .map((child) => (typeof child === "string" ? escape(child) : child.toString()))
70 .join("");
71
72 if (this.tag === "") {
73 // If the tag is empty, it acts as a fragment.
74 return childrenStr;
75 } else {
76 const attrs = [];
77 if (this.attrId) attrs.push(`id="${escape(this.attrId)}"`);
78 if (this.attrClass.length) attrs.push(`class="${escape(this.attrClass.join(" "))}"`);
79 if (this.attrTitle) attrs.push(`title="${escape(this.attrTitle)}"`);
80 if (this.attrStyle) attrs.push(`style="${escape(this.attrStyle)}"`);
81 return `<${this.tag} ${attrs.join(" ")}>${childrenStr}</${this.tag}>`;
82 }
83 }
84
85 /**
86 * Converts the `H` instance into a live DOM element or a DocumentFragment.

Callers 8

jsStackTraceFunction · 0.80
leadingSomethingFunction · 0.80
_strftimeFunction · 0.80
getActiveOrderFunction · 0.80
urlToMapFunction · 0.80
decToHexFunction · 0.80
genTableFunction · 0.80
color.tsFile · 0.80

Calls 1

escapeFunction · 0.50

Tested by

no test coverage detected