MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript /

Class

src/client/sandbox.mjs:467–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}))
466
467Sandbox.Output = class {
468 constructor(div) { this.div = div }
469
470 clear() {
471 let clone = this.div.cloneNode(false)
472 this.div.parentNode.replaceChild(clone, this.div)
473 this.div = clone
474 }
475
476 get empty() {
477 return !this.div.firstChild
478 }
479
480 out(type, args) {
481 let wrap = document.createElement("pre")
482 wrap.className = "sandbox-output-" + type
483 for (let i = 0; i < args.length; ++i) {
484 let arg = args[i]
485 if (i) wrap.appendChild(document.createTextNode(" "))
486 if (typeof arg == "string")
487 wrap.appendChild(document.createTextNode(arg))
488 else
489 wrap.appendChild(represent(arg, 58))
490 }
491 this.div.appendChild(wrap)
492 }
493}
494
495function span(type, text) {
496 let sp = document.createElement("span")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected