MCPcopy
hub / github.com/date-fns/date-fns / execScript

Function execScript

pkgs/core/src/isDate/test.ts:50–65  ·  view source on GitHub ↗
(scriptText: string)

Source from the content-addressed store, hash-verified

48 }
49
50 function execScript(scriptText: string) {
51 const iframe = document.querySelector("iframe#iframe");
52 if (!iframe || !(iframe instanceof HTMLIFrameElement)) {
53 throw new Error("Can't execute the script because iframe isn't found");
54 }
55 const doc = iframe.contentDocument!;
56 const script = doc.createElement("script");
57 script.innerText = scriptText;
58 // @ts-expect-error - We're messing with iframes
59 if (!(doc.body instanceof iframe.contentWindow.HTMLBodyElement)) {
60 throw new Error(
61 "Can't execute the script because iframe does not have body",
62 );
63 }
64 doc.body.append(script);
65 }
66 });
67
68 it("returns false if the given value is not a date object", () => {

Callers 1

test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected