MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / createElementStub

Function createElementStub

app/services/tdc_vm_runner.cjs:52–81  ·  view source on GitHub ↗
(extra = {})

Source from the content-addressed store, hash-verified

50}
51
52function createElementStub(extra = {}) {
53 return makeNoopProxy({
54 style: {},
55 classList: makeNoopProxy({
56 add() {},
57 remove() {},
58 contains() {
59 return false;
60 },
61 }),
62 children: [],
63 childNodes: [],
64 attributes: {},
65 appendChild() {},
66 removeChild() {},
67 insertBefore() {},
68 setAttribute(name, value) {
69 this.attributes[name] = String(value);
70 },
71 getAttribute(name) {
72 return this.attributes[name] ?? null;
73 },
74 getBoundingClientRect() {
75 return { width: 300, height: 150, top: 0, left: 0, right: 300, bottom: 150 };
76 },
77 addEventListener() {},
78 removeEventListener() {},
79 ...extra,
80 });
81}
82
83function buildWindow(input) {
84 const localStorage = makeStorage();

Callers 5

buildWindowFunction · 0.85
createElementFunction · 0.85
getElementsByTagNameFunction · 0.85
querySelectorFunction · 0.85
getElementByIdFunction · 0.85

Calls 1

makeNoopProxyFunction · 0.85

Tested by

no test coverage detected