MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / create

Method create

src/client/sandbox.mjs:20–42  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

18
19export class Sandbox {
20 static async create(options) {
21 this.emptyPath = options.emptyPath || "./"
22 let frame = document.createElement("iframe")
23 frame.src = this.emptyPath + "empty.html"
24 if (options.place) {
25 options.place(frame)
26 } else {
27 frame.style.height = "0px"
28 frame.style.border = "none"
29 document.body.appendChild(frame)
30 }
31 await awaitEvent(frame, "load")
32
33 let box = new Sandbox(frame)
34 let scripts = (options.loadFiles || []).map(file => {
35 let script = box.win.document.createElement("script")
36 script.src = file
37 box.win.document.body.appendChild(script)
38 return awaitEvent(script, "load")
39 })
40 await Promise.all(scripts)
41 return box
42 }
43
44 constructor(frame) {
45 this.startedAt = null

Callers 8

build_code.mjsFile · 0.80
render_html.mjsFile · 0.80
check_links.mjsFile · 0.80
createStateFunction · 0.80
constructorMethod · 0.80
runCodeMethod · 0.80
getSandboxFunction · 0.80
constructorMethod · 0.80

Calls 1

awaitEventFunction · 0.85

Tested by

no test coverage detected