Skip to content

Commit

Permalink
try globalThis instead of global
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbarker committed Jan 4, 2025
1 parent 21d1690 commit c4bb085
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const prepareLiveViewDOM = (document, rootId) => {

describe("events", () => {
beforeEach(() => {
prepareLiveViewDOM(global.document, "root");
prepareLiveViewDOM(globalThis.document, "root");
});

test("send change event to correct target", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const prepareLiveViewDOM = (document, rootId) => {

describe("metadata", () => {
beforeEach(() => {
prepareLiveViewDOM(global.document, "root");
prepareLiveViewDOM(globalThis.document, "root");
});

test("is empty by default", () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/phoenix_live_view_ts/test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { describe, expect, test } from "bun:test";

import { Socket } from "phoenix_ts";
import { closestPhxBinding } from "../src/utils";
import { LiveSocket } from "../assets/js/phoenix_live_view";
import { closestPhxBinding } from "../src/utils";

import {simulateJoinedView, liveViewDOM} from "./test_helpers"
import {liveViewDOM, simulateJoinedView } from "./test_helpers"

let setupView = (content) => {
let el = liveViewDOM(content)
global.document.body.appendChild(el)
globalThis.document.body.appendChild(el)
let liveSocket = new LiveSocket("/live", Socket)
return simulateJoinedView(el, liveSocket)
}
Expand All @@ -21,8 +21,8 @@ describe("utils", () => {
<span id="innerContent">This is a button</span>
</button>
`)
let element = global.document.querySelector("#innerContent")
let parent = global.document.querySelector("#button")
let element = globalThis.document.querySelector("#innerContent")
let parent = globalThis.document.querySelector("#button")
expect(closestPhxBinding(element, "phx-click")).toBe(parent)
})

Expand All @@ -32,7 +32,7 @@ describe("utils", () => {
<span id="innerContent">This is a button</span>
</button>
`)
let element = global.document.querySelector("#innerContent")
let element = globalThis.document.querySelector("#innerContent")
expect(closestPhxBinding(element, "phx-click")).toBe(null)
})
})
Expand Down

0 comments on commit c4bb085

Please sign in to comment.