Skip to content

Commit 72a806f

Browse files
authored
Account for static members in MDN docs (#267)
Static MDN members are suffixed with _static. Like with compatibility data, we should add this suffix when emitting docs.
1 parent 82b94c2 commit 72a806f

17 files changed

+285
-42
lines changed

lib/src/dom/css_typed_om.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ typedef CSSMathOperator = String;
3232
/// API documentation sourced from
3333
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleValue).
3434
extension type CSSStyleValue._(JSObject _) implements JSObject {
35+
/// The **`parse()`** static method of the [CSSStyleValue]
36+
/// interface sets a specific CSS property to the specified values and returns
37+
/// the first
38+
/// value as a [CSSStyleValue] object.
3539
external static CSSStyleValue parse(
3640
String property,
3741
String cssText,
3842
);
43+
44+
/// The **`parseAll()`** static method of the [CSSStyleValue]
45+
/// interface sets all occurrences of a specific CSS property to the specified
46+
/// value and
47+
/// returns an array of [CSSStyleValue] objects, each containing one of the
48+
/// supplied values.
3949
external static JSArray<CSSStyleValue> parseAll(
4050
String property,
4151
String cssText,
@@ -224,6 +234,9 @@ extension type CSSNumericType._(JSObject _) implements JSObject {
224234
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue).
225235
extension type CSSNumericValue._(JSObject _)
226236
implements CSSStyleValue, JSObject {
237+
/// The **`parse()`** static method of the
238+
/// [CSSNumericValue] interface converts a value string into an object whose
239+
/// members are value and the units.
227240
external static CSSNumericValue parse(String cssText);
228241

229242
/// The **`add()`** method of the

lib/src/dom/dom.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,51 @@ extension type AbortController._(JSObject _) implements JSObject {
558558
/// API documentation sourced from
559559
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
560560
extension type AbortSignal._(JSObject _) implements EventTarget, JSObject {
561+
/// The **`AbortSignal.abort()`** static method returns an [AbortSignal] that
562+
/// is already set as aborted (and which does not trigger an
563+
/// [AbortSignal.abort_event] event).
564+
///
565+
/// This is shorthand for the following code:
566+
///
567+
/// ```js
568+
/// const controller = new AbortController();
569+
/// controller.abort();
570+
/// return controller.signal;
571+
/// ```
572+
///
573+
/// This could, for example, be passed to a fetch method in order to run its
574+
/// abort logic (i.e. it may be that code is organized such that the abort
575+
/// logic should be run even if the intended fetch operation has not been
576+
/// started).
577+
///
578+
/// > **Note:** The method is similar in purpose to `Promise.reject`.
561579
external static AbortSignal abort([JSAny? reason]);
580+
581+
/// The **`AbortSignal.timeout()`** static method returns an [AbortSignal]
582+
/// that will automatically abort after a specified time.
583+
///
584+
/// The signal aborts with a `TimeoutError` [DOMException] on timeout, or with
585+
/// `AbortError` [DOMException] due to pressing a browser stop button (or some
586+
/// other inbuilt "stop" operation).
587+
/// This allows UIs to differentiate timeout errors, which typically require
588+
/// user notification, from user-triggered aborts that do not.
589+
///
590+
/// The timeout is based on active rather than elapsed time, and will
591+
/// effectively be paused if the code is running in a suspended worker, or
592+
/// while the document is in a back-forward cache
593+
/// ("[bfcache](https://web.dev/articles/bfcache)").
594+
///
595+
/// To combine multiple signals, you can use [AbortSignal.any_static], for
596+
/// example, to directly abort a download using either a timeout signal or by
597+
/// calling [AbortController.abort].
562598
external static AbortSignal timeout(int milliseconds);
599+
600+
/// The **`AbortSignal.any()`** static method takes an iterable of abort
601+
/// signals and returns an [AbortSignal]. The returned abort signal is aborted
602+
/// when any of the input iterable abort signals are aborted. The
603+
/// [AbortSignal.reason] will be set to the reason of the first signal that is
604+
/// aborted. If any of the given abort signals are already aborted then so
605+
/// will be the returned [AbortSignal].
563606
external static AbortSignal any(JSArray<AbortSignal> signals);
564607

565608
/// The **`throwIfAborted()`** method throws the signal's abort

lib/src/dom/fetch.dart

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,47 @@ extension type Response._(JSObject _) implements JSObject {
419419
ResponseInit init,
420420
]);
421421

422+
/// The **`error()`** static method of the [Response] interface returns a new
423+
/// `Response` object associated with a network error.
424+
///
425+
/// This is mainly useful when writing service workers: it enables a service
426+
/// worker to send a response from a [ServiceWorkerGlobalScope.fetch_event]
427+
/// event handler that will cause the [fetch] call in the main app code to
428+
/// reject the promise.
429+
///
430+
/// An error response has its [Response.type] set to `error`.
422431
external static Response error();
432+
433+
/// The **`redirect()`** static method of the [Response] interface returns a
434+
/// `Response` resulting in a redirect to the specified URL.
435+
///
436+
/// > **Note:** This can be used alongside the
437+
/// > [ServiceWorker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API).
438+
/// > A controlling service worker could intercept a page's request and
439+
/// > redirect it as desired.
440+
/// > This will actually lead to a real redirect if a service worker sends it
441+
/// > upstream.
423442
external static Response redirect(
424443
String url, [
425444
int status,
426445
]);
427446

428-
/// The **`json()`** method of the [Response] interface takes
429-
/// a [Response] stream and reads it to completion. It returns a promise which
430-
/// resolves with the result of parsing the body text as `JSON`.
447+
/// The **`json()`** static method of the [Response] interface returns a
448+
/// `Response` that contains the provided JSON data as body, and a header
449+
/// which is set to `application/json`.
450+
/// The response status, status message, and additional headers can also be
451+
/// set.
431452
///
432-
/// Note that despite the method being named `json()`, the result is not JSON
433-
/// but is instead the result of taking JSON as input and parsing it to
434-
/// produce a JavaScript object.
453+
/// The method makes it easy to create `Response` objects for returning JSON
454+
/// encoded data.
455+
/// [Service workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API),
456+
/// for example, intercept fetch requests made by a browser, and might use
457+
/// `json()` to construct a `Response` from cached JSON data to return to the
458+
/// main thread.
459+
/// The `json()` method can also be used in server code to return JSON data
460+
/// for
461+
/// [single page applications](https://developer.mozilla.org/en-US/docs/Glossary/SPA),
462+
/// and any other applications where a JSON response is expected.
435463
@JS('json')
436464
external static Response json_(
437465
JSAny? data, [

lib/src/dom/geometry.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ extension type DOMPointReadOnly._(JSObject _) implements JSObject {
5151
num w,
5252
]);
5353

54+
/// The static **[DOMPointReadOnly]**
55+
/// method `fromPoint()` creates and returns a new
56+
/// `DOMPointReadOnly` object given a source point.
57+
///
58+
/// You can also create a new `DOMPointReadOnly` object using the
59+
/// [DOMPointReadOnly.DOMPointReadOnly] constructor.
5460
external static DOMPointReadOnly fromPoint([DOMPointInit other]);
5561
external DOMPoint matrixTransform([DOMMatrixInit matrix]);
5662

@@ -125,6 +131,16 @@ extension type DOMPoint._(JSObject _) implements DOMPointReadOnly, JSObject {
125131
num w,
126132
]);
127133

134+
/// The **[DOMPoint]** static method
135+
/// `fromPoint()` creates and returns a new mutable `DOMPoint`
136+
/// object given a source point.
137+
///
138+
/// You can also create a new `DOMPoint` object using the
139+
/// [DOMPoint.DOMPoint] constructor.
140+
///
141+
/// Although this interface is based on `DOMPointReadOnly`, it is not
142+
/// read-only;
143+
/// the properties within may be changed at will.
128144
external static DOMPoint fromPoint([DOMPointInit other]);
129145

130146
/// The **`DOMPoint`** interface's
@@ -197,6 +213,9 @@ extension type DOMRectReadOnly._(JSObject _) implements JSObject {
197213
num height,
198214
]);
199215

216+
/// The **`fromRect()`** static method of the
217+
/// [DOMRectReadOnly] object creates a new `DOMRectReadOnly`
218+
/// object with a given location and dimensions.
200219
external static DOMRectReadOnly fromRect([DOMRectInit other]);
201220
external JSObject toJSON();
202221

@@ -258,6 +277,9 @@ extension type DOMRect._(JSObject _) implements DOMRectReadOnly, JSObject {
258277
num height,
259278
]);
260279

280+
/// The **`fromRect()`** static method of the
281+
/// [DOMRect] object creates a new `DOMRect`
282+
/// object with a given location and dimensions.
261283
external static DOMRect fromRect([DOMRectInit other]);
262284
external double get x;
263285
external set x(num value);

lib/src/dom/html.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6590,6 +6590,12 @@ extension type HTMLScriptElement._(JSObject _)
65906590
/// Creates an [HTMLScriptElement] using the tag 'script'.
65916591
HTMLScriptElement() : _ = document.createElement('script');
65926592

6593+
/// The **`supports()`** static method of the [HTMLScriptElement] interface
6594+
/// provides a simple and consistent method to feature-detect what types of
6595+
/// scripts are supported by the user agent.
6596+
///
6597+
/// The method is expected to return `true` for classic and module scripts,
6598+
/// which are supported by most modern browsers.
65936599
external static bool supports(String type);
65946600

65956601
/// The **`src`** property of the [HTMLScriptElement] interface is a string

lib/src/dom/indexeddb.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,15 +870,33 @@ extension type IDBIndex._(JSObject _) implements JSObject {
870870
/// API documentation sourced from
871871
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/IDBKeyRange).
872872
extension type IDBKeyRange._(JSObject _) implements JSObject {
873+
/// The **`only()`** static method of the [IDBKeyRange]
874+
/// interface creates a new key range containing a single value.
873875
external static IDBKeyRange only(JSAny? value);
876+
877+
/// The **`lowerBound()`** static method of the
878+
/// [IDBKeyRange] interface creates a new key range with only a lower bound.
879+
/// By default, it includes the lower endpoint value and is closed.
874880
external static IDBKeyRange lowerBound(
875881
JSAny? lower, [
876882
bool open,
877883
]);
884+
885+
/// The **`upperBound()`** static method of the
886+
/// [IDBKeyRange] interface creates a new upper-bound key range. By default,
887+
/// it includes the upper endpoint value and is closed.
878888
external static IDBKeyRange upperBound(
879889
JSAny? upper, [
880890
bool open,
881891
]);
892+
893+
/// The **`bound()`** static method of the [IDBKeyRange]
894+
/// interface creates a new key range with the specified upper and lower
895+
/// bounds. The
896+
/// bounds can be open (that is, the bounds exclude the endpoint values) or
897+
/// closed (that
898+
/// is, the bounds include the endpoint values). By default, the bounds are
899+
/// closed.
882900
external static IDBKeyRange bound(
883901
JSAny? lower,
884902
JSAny? upper, [

lib/src/dom/media_source.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,23 @@ typedef AppendMode = String;
3333
extension type MediaSource._(JSObject _) implements EventTarget, JSObject {
3434
external factory MediaSource();
3535

36+
/// The **`MediaSource.isTypeSupported()`** static method returns a boolean
37+
/// value which is `true` if the given MIME type and (optional) codec are
38+
/// _likely_ to be supported by the current .
39+
///
40+
/// That is, if it can successfully create [SourceBuffer] objects for that
41+
/// media type.
42+
/// If the returned value is `false`, then the user agent is certain that it
43+
/// _cannot_ access media of the specified format.
3644
external static bool isTypeSupported(String type);
45+
46+
/// The **`canConstructInDedicatedWorker`** static property of the
47+
/// [MediaSource] interface returns `true` if `MediaSource` worker support is
48+
/// implemented, providing a low-latency feature detection mechanism.
49+
///
50+
/// If this were not available, the alternative would be a much higher latency
51+
/// approach such as attempting the creation of a `MediaSource` object from a
52+
/// dedicated worker and transferring the result back to the main thread.
3753
external static bool get canConstructInDedicatedWorker;
3854

3955
/// The **`addSourceBuffer()`** method of the

lib/src/dom/mediastream_recording.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ extension type MediaRecorder._(JSObject _) implements EventTarget, JSObject {
3737
MediaRecorderOptions options,
3838
]);
3939

40+
/// The **`isTypeSupported()`** static method of the [MediaRecorder] interface
41+
/// returns a `Boolean` which is `true` if the MIME media type specified is
42+
/// one the user agent should be able to successfully record.
4043
external static bool isTypeSupported(String type);
4144

4245
/// The **`start()`** method of the [MediaRecorder] interface begins recording

lib/src/dom/notifications.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ extension type Notification._(JSObject _) implements EventTarget, JSObject {
4040
NotificationOptions options,
4141
]);
4242

43+
/// The **`requestPermission()`** static method of the [Notification]
44+
/// interface requests permission from the user for the current origin to
45+
/// display notifications.
4346
external static JSPromise<JSString> requestPermission(
4447
[NotificationPermissionCallback deprecatedCallback]);
48+
49+
/// The **`permission`** read-only static property of the [Notification]
50+
/// interface indicates the current permission granted by the user for the
51+
/// current origin to
52+
/// display web notifications.
4553
external static NotificationPermission get permission;
4654

4755
/// The **`close()`** method of the [Notification] interface is used to

lib/src/dom/performance_timeline.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ extension type PerformanceEntry._(JSObject _) implements JSObject {
9191
extension type PerformanceObserver._(JSObject _) implements JSObject {
9292
external factory PerformanceObserver(PerformanceObserverCallback callback);
9393

94+
/// The static **`supportedEntryTypes`** read-only property of the
95+
/// [PerformanceObserver] interface returns an array of the
96+
/// [PerformanceEntry.entryType] values supported by the user agent.
97+
///
98+
/// As the list of supported entries varies per browser and is evolving, this
99+
/// property allows web developers to check which are available.
94100
external static JSArray<JSString> get supportedEntryTypes;
95101

96102
/// The **`observe()`** method of the **[PerformanceObserver]** interface is

lib/src/dom/push_api.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ typedef PushEncryptionKeyName = String;
3333
/// API documentation sourced from
3434
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/PushManager).
3535
extension type PushManager._(JSObject _) implements JSObject {
36+
/// The **`supportedContentEncodings`** read-only static property of the
37+
/// [PushManager] interface returns an array of supported content codings that
38+
/// can be used to encrypt the payload of a push message.
3639
external static JSArray<JSString> get supportedContentEncodings;
3740

3841
/// The **`subscribe()`** method of the [PushManager]

lib/src/dom/url.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,69 @@ extension type URL._(JSObject _) implements JSObject {
3636
String base,
3737
]);
3838

39+
/// @AvailableInWorkers("window_and_worker_except_service")
40+
///
41+
/// The **`createObjectURL()`** static method of the [URL] interface
42+
/// creates a string containing a URL representing the object given in the
43+
/// parameter.
44+
///
45+
/// The URL lifetime is tied to the [document]
46+
/// in the window on which it was created. The new object URL represents the
47+
/// specified
48+
/// [File] object or [Blob] object.
49+
///
50+
/// To release an object URL, call [URL.revokeObjectURL_static].
51+
///
52+
/// > **Note:** This feature is _not_ available in
53+
/// > [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)
54+
/// > due to its
55+
/// > potential to create memory leaks.
3956
external static String createObjectURL(JSObject obj);
57+
58+
/// @AvailableInWorkers("window_and_worker_except_service")
59+
///
60+
/// The **`revokeObjectURL()`** static method of the [URL] interface
61+
/// releases an existing object URL which was previously created by calling
62+
/// [URL.createObjectURL_static].
63+
///
64+
/// Call this method when you've finished
65+
/// using an object URL to let the browser know not to keep the reference to
66+
/// the file any
67+
/// longer.
68+
///
69+
/// > **Note:** This method is _not_ available in
70+
/// > [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API),
71+
/// > due to
72+
/// > issues with the [Blob] interface's life cycle and the potential for
73+
/// > leaks.
4074
external static void revokeObjectURL(String url);
75+
76+
/// The **`URL.parse()`** static method of the [URL] interface returns a newly
77+
/// created [URL] object representing the URL defined by the parameters.
78+
///
79+
/// If the given base URL or the resulting URL are not parsable and valid
80+
/// URLs, `null` is returned.
81+
/// This is an alternative to using the [URL.URL] constructor to construct a
82+
/// `URL` within a
83+
/// [try...catch](/en-US/docs/Web/JavaScript/Reference/Statements/try...catch)
84+
/// block, or using [URL.canParse_static] to check the parameters and
85+
/// returning `null` if the method returns `false`.
4186
external static URL? parse(
4287
String url, [
4388
String base,
4489
]);
90+
91+
/// The **`URL.canParse()`** static method of the [URL] interface returns a
92+
/// boolean indicating whether or not an absolute URL, or a relative URL
93+
/// combined with a base URL, are parsable and valid.
94+
///
95+
/// This is a fast and easy alternative to constructing a `URL` within a
96+
/// [try...catch](/en-US/docs/Web/JavaScript/Reference/Statements/try...catch)
97+
/// block.
98+
/// It returns `true` for the same values for which the [`URL()`
99+
/// constructor](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL)
100+
/// would succeed, and `false` for the values that would cause the constructor
101+
/// to throw.
45102
external static bool canParse(
46103
String url, [
47104
String base,

0 commit comments

Comments
 (0)