Clients: matchAll() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

matchAll()Clients インターフェイスのメソッドで、サービスワーカークライアント(Client)オブジェクトのリストの Promise を返します。 関連するサービスワーカーのオリジンと同じオリジンを持つすべてのサービスワーカークライアントを返すには、options 引数を含めます。 オプションが含まれていなかった場合、このメソッドは、サービスワーカーによって制御されるサービスワーカークライアントのみを返します。

構文

js
matchAll()
matchAll(options)

引数

options 省略可

照合操作のオプションを設定できるオプションオブジェクト。 利用可能なオプションは次のとおりです。

includeUncontrolled

論理値です。true に設定すると、照合操作は、現在のサービスワーカーと同じオリジンを共有するすべてのクライアントを返します。 それ以外の場合は、現在のサービスワーカーによって制御されているサービスワーカークライアントのみを返します。 既定値は false です。

type

照合するクライアントの種類を設定します。 使用可能な値は、"window""worker""sharedworker""all" です。 既定値は "window" です。

返値

Client オブジェクトの配列に解決される Promise。 Chrome 46/Firefox 54 以降では、このメソッドはクライアントを直近でフォーカスした順序で返し、仕様どおりに修正されました

js
clients.matchAll(options).then((clientList) => {
  for (const client of clientList) {
    if (client.url === "index.html") {
      clients.openWindow(client);
      // または、一致するクライアントに関係する何かを行う
    }
  }
});

仕様書

Specification
Service Workers
# clients-matchall

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
matchAll
options.includeUncontrolled parameter

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.