Skip to content

Commit 7bfb330

Browse files
committed
Use globalThis instead of global
1 parent fae2df5 commit 7bfb330

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Sources/DOMKit/ECMAScript/Support.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44

55
import JavaScriptKit
66

7-
public class Global {
8-
public let jsObject = JSObject.global
9-
public let document: Document
10-
11-
init() {
12-
document = Document(unsafelyWrapping: jsObject.document.object!)
13-
}
7+
public extension Window {
8+
public var document: Document { Document(unsafelyWrapping: jsObject.document.object!) }
149
}
1510

1611
public extension Document {
@@ -25,7 +20,7 @@ public extension HTMLElement {
2520
}
2621
}
2722

28-
public let global = Global()
23+
public let globalThis = Window(from: JSObject.global.jsValue())!
2924

3025
public class ReadableStream: JSBridgedClass {
3126

Tests/DOMKitTests/DOMKitTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import DOMKit
33

44
final class DOMKitTests: XCTestCase {
55
func testExample() {
6-
let document = global.document
6+
let document = globalThis.document
77
let button = document.createElement(localName: "button")
88
button.textContent = "Hello, world!"
99
button.addEventListener(type: "click") { event in

0 commit comments

Comments
 (0)