Skip to content

Commit 51e594b

Browse files
authored
Fix dictionary constructors to accept supertype members and create an empty object when there are no fields (#197)
Dictionaries can contain their supertypes' members as well and therefore, these constructors should accept them. https://webidl.spec.whatwg.org/#idl-dictionaries #188 We also emit some empty dictionary constructors, but because they are empty, they are treated as named constructors instead of object literal constructors. They should instead call JSObject() to create an empty object. Since some supertype fields are marked required, this is technically a breaking change as calling the same dictionary constructor requires those members now. Therefore, bump to 0.6.0-wip.
1 parent 4af904f commit 51e594b

40 files changed

+835
-90
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.6.0-wip
2+
3+
- Added supertypes' fields to dictionary constructors as dictionaries are
4+
allowed to contain those fields.
5+
- Empty dictionary constructors now create an empty object instead of being
6+
treated like non-object literal `external` constructors.
7+
18
## 0.5.1
29

310
- Add [`TrustedTypes`](https://web.dev/trusted-types) members.

lib/src/dom/clipboard_apis.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ typedef ClipboardItemData = JSPromise<JSAny>;
2222
typedef ClipboardItems = JSArray<ClipboardItem>;
2323
typedef PresentationStyle = String;
2424
extension type ClipboardEventInit._(JSObject _) implements EventInit, JSObject {
25-
external factory ClipboardEventInit({DataTransfer? clipboardData});
25+
external factory ClipboardEventInit({
26+
bool bubbles,
27+
bool cancelable,
28+
bool composed,
29+
DataTransfer? clipboardData,
30+
});
2631

2732
external set clipboardData(DataTransfer? value);
2833
external DataTransfer? get clipboardData;
@@ -136,7 +141,10 @@ extension type ClipboardUnsanitizedFormats._(JSObject _) implements JSObject {
136141
}
137142
extension type ClipboardPermissionDescriptor._(JSObject _)
138143
implements PermissionDescriptor, JSObject {
139-
external factory ClipboardPermissionDescriptor({bool allowWithoutGesture});
144+
external factory ClipboardPermissionDescriptor({
145+
required String name,
146+
bool allowWithoutGesture,
147+
});
140148

141149
external set allowWithoutGesture(bool value);
142150
external bool get allowWithoutGesture;

lib/src/dom/credential_management.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ extension type PasswordCredential._(JSObject _)
188188
extension type PasswordCredentialData._(JSObject _)
189189
implements CredentialData, JSObject {
190190
external factory PasswordCredentialData({
191+
required String id,
191192
String name,
192193
String iconURL,
193194
required String origin,
@@ -243,6 +244,7 @@ extension type FederatedCredentialRequestOptions._(JSObject _)
243244
extension type FederatedCredentialInit._(JSObject _)
244245
implements CredentialData, JSObject {
245246
external factory FederatedCredentialInit({
247+
required String id,
246248
String name,
247249
String iconURL,
248250
required String origin,

lib/src/dom/csp.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ extension type SecurityPolicyViolationEvent._(JSObject _)
7272
extension type SecurityPolicyViolationEventInit._(JSObject _)
7373
implements EventInit, JSObject {
7474
external factory SecurityPolicyViolationEventInit({
75+
bool bubbles,
76+
bool cancelable,
77+
bool composed,
7578
required String documentURI,
7679
String referrer,
7780
String blockedURI,

lib/src/dom/css_animations.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ extension type AnimationEvent._(JSObject _) implements Event, JSObject {
3131
}
3232
extension type AnimationEventInit._(JSObject _) implements EventInit, JSObject {
3333
external factory AnimationEventInit({
34+
bool bubbles,
35+
bool cancelable,
36+
bool composed,
3437
String animationName,
3538
num elapsedTime,
3639
String pseudoElement,

lib/src/dom/css_font_loading.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ extension type FontFacePalettes._(JSObject _) implements JSObject {
126126
}
127127
extension type FontFaceSetLoadEventInit._(JSObject _)
128128
implements EventInit, JSObject {
129-
external factory FontFaceSetLoadEventInit({JSArray<FontFace> fontfaces});
129+
external factory FontFaceSetLoadEventInit({
130+
bool bubbles,
131+
bool cancelable,
132+
bool composed,
133+
JSArray<FontFace> fontfaces,
134+
});
130135

131136
external set fontfaces(JSArray<FontFace> value);
132137
external JSArray<FontFace> get fontfaces;

lib/src/dom/css_transitions.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ extension type TransitionEvent._(JSObject _) implements Event, JSObject {
3131
extension type TransitionEventInit._(JSObject _)
3232
implements EventInit, JSObject {
3333
external factory TransitionEventInit({
34+
bool bubbles,
35+
bool cancelable,
36+
bool composed,
3437
String propertyName,
3538
num elapsedTime,
3639
String pseudoElement,

lib/src/dom/cssom_view.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extension type ScrollOptions._(JSObject _) implements JSObject {
3131
extension type ScrollToOptions._(JSObject _)
3232
implements ScrollOptions, JSObject {
3333
external factory ScrollToOptions({
34+
ScrollBehavior behavior,
3435
num left,
3536
num top,
3637
});
@@ -99,6 +100,9 @@ extension type MediaQueryListEvent._(JSObject _) implements Event, JSObject {
99100
extension type MediaQueryListEventInit._(JSObject _)
100101
implements EventInit, JSObject {
101102
external factory MediaQueryListEventInit({
103+
bool bubbles,
104+
bool cancelable,
105+
bool composed,
102106
String media,
103107
bool matches,
104108
});
@@ -135,6 +139,7 @@ extension type CaretPosition._(JSObject _) implements JSObject {
135139
extension type ScrollIntoViewOptions._(JSObject _)
136140
implements ScrollOptions, JSObject {
137141
external factory ScrollIntoViewOptions({
142+
ScrollBehavior behavior,
138143
ScrollLogicalPosition block,
139144
ScrollLogicalPosition inline,
140145
});

lib/src/dom/dom.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,12 @@ extension type CustomEvent._(JSObject _) implements Event, JSObject {
218218
external JSAny? get detail;
219219
}
220220
extension type CustomEventInit._(JSObject _) implements EventInit, JSObject {
221-
external factory CustomEventInit({JSAny? detail});
221+
external factory CustomEventInit({
222+
bool bubbles,
223+
bool cancelable,
224+
bool composed,
225+
JSAny? detail,
226+
});
222227

223228
external set detail(JSAny? value);
224229
external JSAny? get detail;
@@ -363,6 +368,7 @@ extension type EventListenerOptions._(JSObject _) implements JSObject {
363368
extension type AddEventListenerOptions._(JSObject _)
364369
implements EventListenerOptions, JSObject {
365370
external factory AddEventListenerOptions({
371+
bool capture,
366372
bool passive,
367373
bool once,
368374
AbortSignal signal,

lib/src/dom/encrypted_media.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ extension type MediaKeyMessageEvent._(JSObject _) implements Event, JSObject {
188188
extension type MediaKeyMessageEventInit._(JSObject _)
189189
implements EventInit, JSObject {
190190
external factory MediaKeyMessageEventInit({
191+
bool bubbles,
192+
bool cancelable,
193+
bool composed,
191194
required MediaKeyMessageType messageType,
192195
required JSArrayBuffer message,
193196
});
@@ -215,6 +218,9 @@ extension type MediaEncryptedEvent._(JSObject _) implements Event, JSObject {
215218
extension type MediaEncryptedEventInit._(JSObject _)
216219
implements EventInit, JSObject {
217220
external factory MediaEncryptedEventInit({
221+
bool bubbles,
222+
bool cancelable,
223+
bool composed,
218224
String initDataType,
219225
JSArrayBuffer? initData,
220226
});

lib/src/dom/fileapi.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ extension type File._(JSObject _) implements Blob, JSObject {
103103
}
104104
extension type FilePropertyBag._(JSObject _)
105105
implements BlobPropertyBag, JSObject {
106-
external factory FilePropertyBag({int lastModified});
106+
external factory FilePropertyBag({
107+
String type,
108+
EndingType endings,
109+
int lastModified,
110+
});
107111

108112
external set lastModified(int value);
109113
external int get lastModified;

lib/src/dom/gamepad.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ extension type GamepadEvent._(JSObject _) implements Event, JSObject {
9999
external Gamepad get gamepad;
100100
}
101101
extension type GamepadEventInit._(JSObject _) implements EventInit, JSObject {
102-
external factory GamepadEventInit({required Gamepad gamepad});
102+
external factory GamepadEventInit({
103+
bool bubbles,
104+
bool cancelable,
105+
bool composed,
106+
required Gamepad gamepad,
107+
});
103108

104109
external set gamepad(Gamepad value);
105110
external Gamepad get gamepad;

lib/src/dom/geometry.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,18 @@ extension type DOMMatrix2DInit._(JSObject _) implements JSObject {
458458
extension type DOMMatrixInit._(JSObject _)
459459
implements DOMMatrix2DInit, JSObject {
460460
external factory DOMMatrixInit({
461+
num a,
462+
num b,
463+
num c,
464+
num d,
465+
num e,
466+
num f,
467+
num m11,
468+
num m12,
469+
num m21,
470+
num m22,
471+
num m41,
472+
num m42,
461473
num m13,
462474
num m14,
463475
num m23,

0 commit comments

Comments
 (0)