Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dictionary constructors to accept supertype members and create an empty object when there are no fields #197

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.6.0-wip

- Added supertypes' fields to dictionary constructors as dictionaries are
allowed to contain those fields.
- Empty dictionary constructors now create an empty object instead of being
treated like non-object literal `external` constructors.

## 0.5.1

- Add [`TrustedTypes`](https://web.dev/trusted-types) members.
Expand Down
12 changes: 10 additions & 2 deletions lib/src/dom/clipboard_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ typedef ClipboardItemData = JSPromise<JSAny>;
typedef ClipboardItems = JSArray<ClipboardItem>;
typedef PresentationStyle = String;
extension type ClipboardEventInit._(JSObject _) implements EventInit, JSObject {
external factory ClipboardEventInit({DataTransfer? clipboardData});
external factory ClipboardEventInit({
bool bubbles,
bool cancelable,
bool composed,
DataTransfer? clipboardData,
});

external set clipboardData(DataTransfer? value);
external DataTransfer? get clipboardData;
Expand Down Expand Up @@ -136,7 +141,10 @@ extension type ClipboardUnsanitizedFormats._(JSObject _) implements JSObject {
}
extension type ClipboardPermissionDescriptor._(JSObject _)
implements PermissionDescriptor, JSObject {
external factory ClipboardPermissionDescriptor({bool allowWithoutGesture});
external factory ClipboardPermissionDescriptor({
required String name,
bool allowWithoutGesture,
});

external set allowWithoutGesture(bool value);
external bool get allowWithoutGesture;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/dom/credential_management.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ extension type PasswordCredential._(JSObject _)
extension type PasswordCredentialData._(JSObject _)
implements CredentialData, JSObject {
external factory PasswordCredentialData({
required String id,
String name,
String iconURL,
required String origin,
Expand Down Expand Up @@ -243,6 +244,7 @@ extension type FederatedCredentialRequestOptions._(JSObject _)
extension type FederatedCredentialInit._(JSObject _)
implements CredentialData, JSObject {
external factory FederatedCredentialInit({
required String id,
String name,
String iconURL,
required String origin,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/dom/csp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ extension type SecurityPolicyViolationEvent._(JSObject _)
extension type SecurityPolicyViolationEventInit._(JSObject _)
implements EventInit, JSObject {
external factory SecurityPolicyViolationEventInit({
bool bubbles,
bool cancelable,
bool composed,
required String documentURI,
String referrer,
String blockedURI,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/dom/css_animations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ extension type AnimationEvent._(JSObject _) implements Event, JSObject {
}
extension type AnimationEventInit._(JSObject _) implements EventInit, JSObject {
external factory AnimationEventInit({
bool bubbles,
bool cancelable,
bool composed,
String animationName,
num elapsedTime,
String pseudoElement,
Expand Down
7 changes: 6 additions & 1 deletion lib/src/dom/css_font_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ extension type FontFacePalettes._(JSObject _) implements JSObject {
}
extension type FontFaceSetLoadEventInit._(JSObject _)
implements EventInit, JSObject {
external factory FontFaceSetLoadEventInit({JSArray<FontFace> fontfaces});
external factory FontFaceSetLoadEventInit({
bool bubbles,
bool cancelable,
bool composed,
JSArray<FontFace> fontfaces,
});

external set fontfaces(JSArray<FontFace> value);
external JSArray<FontFace> get fontfaces;
Expand Down
3 changes: 3 additions & 0 deletions lib/src/dom/css_transitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ extension type TransitionEvent._(JSObject _) implements Event, JSObject {
extension type TransitionEventInit._(JSObject _)
implements EventInit, JSObject {
external factory TransitionEventInit({
bool bubbles,
bool cancelable,
bool composed,
String propertyName,
num elapsedTime,
String pseudoElement,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/dom/cssom_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension type ScrollOptions._(JSObject _) implements JSObject {
extension type ScrollToOptions._(JSObject _)
implements ScrollOptions, JSObject {
external factory ScrollToOptions({
ScrollBehavior behavior,
num left,
num top,
});
Expand Down Expand Up @@ -99,6 +100,9 @@ extension type MediaQueryListEvent._(JSObject _) implements Event, JSObject {
extension type MediaQueryListEventInit._(JSObject _)
implements EventInit, JSObject {
external factory MediaQueryListEventInit({
bool bubbles,
bool cancelable,
bool composed,
String media,
bool matches,
});
Expand Down Expand Up @@ -135,6 +139,7 @@ extension type CaretPosition._(JSObject _) implements JSObject {
extension type ScrollIntoViewOptions._(JSObject _)
implements ScrollOptions, JSObject {
external factory ScrollIntoViewOptions({
ScrollBehavior behavior,
ScrollLogicalPosition block,
ScrollLogicalPosition inline,
});
Expand Down
8 changes: 7 additions & 1 deletion lib/src/dom/dom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ extension type CustomEvent._(JSObject _) implements Event, JSObject {
external JSAny? get detail;
}
extension type CustomEventInit._(JSObject _) implements EventInit, JSObject {
external factory CustomEventInit({JSAny? detail});
external factory CustomEventInit({
bool bubbles,
kevmoo marked this conversation as resolved.
Show resolved Hide resolved
bool cancelable,
bool composed,
JSAny? detail,
});

external set detail(JSAny? value);
external JSAny? get detail;
Expand Down Expand Up @@ -363,6 +368,7 @@ extension type EventListenerOptions._(JSObject _) implements JSObject {
extension type AddEventListenerOptions._(JSObject _)
implements EventListenerOptions, JSObject {
external factory AddEventListenerOptions({
bool capture,
bool passive,
bool once,
AbortSignal signal,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/dom/encrypted_media.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ extension type MediaKeyMessageEvent._(JSObject _) implements Event, JSObject {
extension type MediaKeyMessageEventInit._(JSObject _)
implements EventInit, JSObject {
external factory MediaKeyMessageEventInit({
bool bubbles,
bool cancelable,
bool composed,
required MediaKeyMessageType messageType,
required JSArrayBuffer message,
});
Expand Down Expand Up @@ -215,6 +218,9 @@ extension type MediaEncryptedEvent._(JSObject _) implements Event, JSObject {
extension type MediaEncryptedEventInit._(JSObject _)
implements EventInit, JSObject {
external factory MediaEncryptedEventInit({
bool bubbles,
bool cancelable,
bool composed,
String initDataType,
JSArrayBuffer? initData,
});
Expand Down
6 changes: 5 additions & 1 deletion lib/src/dom/fileapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ extension type File._(JSObject _) implements Blob, JSObject {
}
extension type FilePropertyBag._(JSObject _)
implements BlobPropertyBag, JSObject {
external factory FilePropertyBag({int lastModified});
external factory FilePropertyBag({
String type,
EndingType endings,
int lastModified,
});

external set lastModified(int value);
external int get lastModified;
Expand Down
7 changes: 6 additions & 1 deletion lib/src/dom/gamepad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ extension type GamepadEvent._(JSObject _) implements Event, JSObject {
external Gamepad get gamepad;
}
extension type GamepadEventInit._(JSObject _) implements EventInit, JSObject {
external factory GamepadEventInit({required Gamepad gamepad});
external factory GamepadEventInit({
bool bubbles,
bool cancelable,
bool composed,
required Gamepad gamepad,
});

external set gamepad(Gamepad value);
external Gamepad get gamepad;
Expand Down
12 changes: 12 additions & 0 deletions lib/src/dom/geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,18 @@ extension type DOMMatrix2DInit._(JSObject _) implements JSObject {
extension type DOMMatrixInit._(JSObject _)
implements DOMMatrix2DInit, JSObject {
external factory DOMMatrixInit({
num a,
num b,
num c,
num d,
num e,
num f,
num m11,
num m12,
num m21,
num m22,
num m41,
num m42,
num m13,
num m14,
num m23,
Expand Down
Loading