Skip to content

Commit bdf22cf

Browse files
committed
Don’t force unwrap fromJSValue result when returning an optional
1 parent 9eba395 commit bdf22cf

File tree

10 files changed

+197
-186
lines changed

10 files changed

+197
-186
lines changed

Patches/DOM.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--- a/Sources/DOM/Generated.swift
22
+++ b/Sources/DOM/Generated.swift
3-
@@ -1005,8 +1005,15 @@ public class BeforeUnloadEvent: Event {
3+
@@ -1006,8 +1006,15 @@ public class BeforeUnloadEvent: Event {
44
super.init(unsafelyWrapping: jsObject)
55
}
6-
6+
77
+ @available(*, unavailable)
88
+ override public var returnValue: Bool {
99
+ get { !_returnValue.wrappedValue.isEmpty }
@@ -17,20 +17,20 @@
1717
get { _returnValue.wrappedValue }
1818
set { _returnValue.wrappedValue = newValue }
1919
}
20-
@@ -7069,7 +7076,8 @@ public class HTMLFormControlsCollection: HTMLCollection {
20+
@@ -7070,7 +7077,8 @@ public class HTMLFormControlsCollection: HTMLCollection {
2121
jsObject[key].fromJSValue()
2222
}
23-
23+
2424
- @inlinable override public func namedItem(name: String) -> Element_or_RadioNodeList? {
2525
+ // `override` removed since the superclass returns a more constrained type `Element`
2626
+ @inlinable func namedItem(name: String) -> Element_or_RadioNodeList? {
2727
let this = jsObject
28-
return this[Strings.namedItem].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()!
28+
return this[Strings.namedItem].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()
2929
}
30-
@@ -20376,19 +20384,9 @@ public enum CanvasImageSource: JSValueCompatible, Any_CanvasImageSource {
30+
@@ -20369,19 +20377,9 @@ public enum CanvasImageSource: JSValueCompatible, Any_CanvasImageSource {
3131
self = val
3232
}
33-
33+
3434
- init(_ htmlOrSVGImageElement: HTMLOrSVGImageElement) {
3535
- let val: CanvasImageSource = .htmlOrSVGImageElement(htmlOrSVGImageElement)
3636
- self = val
@@ -47,12 +47,12 @@
4747
+ let val: CanvasImageSource = .htmlOrSVGImageElement(htmlImageElement)
4848
+ self = val
4949
}
50-
50+
5151
init(_ htmlVideoElement: HTMLVideoElement) {
52-
@@ -21636,18 +21634,8 @@ public enum ImageBitmapSource: JSValueCompatible, Any_ImageBitmapSource {
52+
@@ -21629,18 +21627,8 @@ public enum ImageBitmapSource: JSValueCompatible, Any_ImageBitmapSource {
5353
self = .init(val)
5454
}
55-
55+
5656
- init(_ htmlOrSVGImageElement: HTMLOrSVGImageElement) {
5757
- let val: CanvasImageSource = .htmlOrSVGImageElement(htmlOrSVGImageElement)
5858
- self = .init(val)
@@ -68,4 +68,4 @@
6868
+ let val: CanvasImageSource = .htmlOrSVGImageElement(htmlImageElement)
6969
self = .init(val)
7070
}
71-
71+

Sources/CSSOM/Generated.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ public class CSSRuleList: JSBridgedClass {
11491149

11501150
@inlinable public func item(index: UInt32) -> CSSRule? {
11511151
let this = jsObject
1152-
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()!
1152+
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()
11531153
}
11541154

11551155
@ReadonlyAttribute
@@ -1595,7 +1595,7 @@ public class CaretPosition: JSBridgedClass {
15951595

15961596
@inlinable public func getClientRect() -> DOMRect? {
15971597
let this = jsObject
1598-
return this[Strings.getClientRect].function!(this: this, arguments: []).fromJSValue()!
1598+
return this[Strings.getClientRect].function!(this: this, arguments: []).fromJSValue()
15991599
}
16001600
}
16011601

@@ -1682,7 +1682,7 @@ public extension GeometryUtils {
16821682

16831683
public protocol LinkStyle: JSBridgedClass {}
16841684
public extension LinkStyle {
1685-
@inlinable var sheet: CSSStyleSheet? { jsObject[Strings.sheet].fromJSValue()! }
1685+
@inlinable var sheet: CSSStyleSheet? { jsObject[Strings.sheet].fromJSValue() }
16861686
}
16871687

16881688
public class MediaList: JSBridgedClass {
@@ -1708,7 +1708,7 @@ public class MediaList: JSBridgedClass {
17081708

17091709
@inlinable public func item(index: UInt32) -> String? {
17101710
let this = jsObject
1711-
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()!
1711+
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()
17121712
}
17131713

17141714
@inlinable public func appendMedium(medium: String) {
@@ -2040,7 +2040,7 @@ public class StyleSheetList: JSBridgedClass {
20402040

20412041
@inlinable public func item(index: UInt32) -> CSSStyleSheet? {
20422042
let this = jsObject
2043-
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()!
2043+
return this[Strings.item].function!(this: this, arguments: [_toJSValue(index)]).fromJSValue()
20442044
}
20452045

20462046
@ReadonlyAttribute

0 commit comments

Comments
 (0)