MCPcopy Create free account
hub / github.com/TruthHun/BookStack / DocumentFragment

Class DocumentFragment

static/katex/katex.mjs:884–944  ·  view source on GitHub ↗

* This node represents a document fragment, which contains elements, but when * placed into the DOM doesn't have any representation itself. It only contains * children and doesn't have any DOM node properties.

Source from the content-addressed store, hash-verified

882 * children and doesn't have any DOM node properties.
883 */
884class DocumentFragment {
885 // HtmlDomNode
886 // Never used; needed for satisfying interface.
887 constructor(children) {
888 this.children = void 0;
889 this.classes = void 0;
890 this.height = void 0;
891 this.depth = void 0;
892 this.maxFontSize = void 0;
893 this.style = void 0;
894 this.children = children;
895 this.classes = [];
896 this.height = 0;
897 this.depth = 0;
898 this.maxFontSize = 0;
899 this.style = {};
900 }
901
902 hasClass(className) {
903 return utils.contains(this.classes, className);
904 }
905 /** Convert the fragment into a node. */
906
907
908 toNode() {
909 const frag = document.createDocumentFragment();
910
911 for (let i = 0; i < this.children.length; i++) {
912 frag.appendChild(this.children[i].toNode());
913 }
914
915 return frag;
916 }
917 /** Convert the fragment into HTML markup. */
918
919
920 toMarkup() {
921 let markup = ""; // Simply concatenate the markup for the children together.
922
923 for (let i = 0; i < this.children.length; i++) {
924 markup += this.children[i].toMarkup();
925 }
926
927 return markup;
928 }
929 /**
930 * Converts the math node into a string, similar to innerText. Applies to
931 * MathDomNode's only.
932 */
933
934
935 toText() {
936 // To avoid this, we would subclass documentFragment separately for
937 // MathML, but polyfills for subclassing is expensive per PR 1469.
938 // $FlowFixMe: Only works for ChildType = MathDomNode.
939 const toText = child => child.toText();
940
941 return this.children.map(toText).join("");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected