[19] [DFN[[CODE(JS)@en[window.customElements]]]] 
([DFN[[CODE(DOMi)@en[CustomElementRegistry]]]])
は、[[カスタム要素定義]]を保持している[[オブジェクト]]です。

* 仕様書

[REFS[
- [3] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-05-14 09:55:50 +09:00]]) <https://html.spec.whatwg.org/#custom-elements-api>
]REFS]

* 状態

[7] [CODE(DOMi)@en[CustomElementRegistry]] [[オブジェクト]]は、
次の状態を持ちます。
[FIG(list members)[
: [F[[[カスタム要素定義]]の[[集合]]]] :
[[カスタム要素定義を探す]]手順で参照します。
初期状態では[[空]]です [SRC[>>3]]。
: [F[定義時約束写像]] :
[[妥当なカスタム要素名]]から[[約束]]への[[写像]]です [SRC[>>3]]。
[CODE(DOMm)@en[whenDefined]] で使われます。
初期状態では[[空]]です。
: [F[要素定義が走っている]] :

[HISTORY[
: [F[定義される名前の集合]] :
: [F[定義される構築器の集合]] :
]HISTORY]
]FIG]

* メンバー

[6] [CODE(DOMi)@en[CustomElementRegistry]] [[インターフェイス]]は、
次の[[メンバー]]を持ちます。

[FIG(short list)[ [20] [CODE(DOMi)@en[CustomElementRegistry]] の[[メンバー][インターフェイスメンバー]]
- [CODE(DOMm)@en[define]]
- [CODE(DOMm)@en[get][CustomElementsRegistry]]
- [CODE(DOMm)@en[whenDefined]]
- [CODE(DOMm)@en[upgrade][要素の格上げ]]
]FIG]

* 文脈

[8] [CODE(DOMi)@en[CustomElementsRegistry]] [[インターフェイス]]は、
[[文書環境]]に[[晒され]]ます。

[9] [CODE(DOMi)@en[CustomElementsRegistry]] [[オブジェクト]]は、
[CODE(DOMi)@en[Window]] [[オブジェクト]]に関連付けられており、
[CODE(DOMa)@en[customElements]] [[IDL属性]]から参照できます。

* [CODE(DOMi)@en[Window]] インターフェイス [CODE(DOMa)@en[customElements]] 属性

[4] [CODE(DOMi)@en[Window]] は、 [DFN[[F[[CODE(DOMi)@en[CustomElementsRegistry]]]]]]
を持ちます [SRC[>>3]]。作成時に設定され [SRC[>>3]]、以後変化しません。

[5] [CODE(DOMi)@en[Window]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[customElements]]]] [[IDL属性]]の[[取得器]]は、
[[文脈オブジェクト]]の [F[[CODE(DOMi)@en[CustomElementsRegistry]]]]
を返さなければ[MUST[なりません]] [SRC[>>3]]。

* [CODE(DOMi)@en[CustomElementsRegistry]] インターフェイス [CODE(DOMm)@en[get][CustomElementsRegistry]] メソッド

[10] [CODE(DOMi)@en[CustomElementsRegistry]] [[インターフェイス]]の
[DFN[[CODE(DOMm)@en[get][CustomElementsRegistry]]]] [[メソッド]]は、
次のようにしなければ[MUST[なりません]] [SRC[>>3]]。

[FIG(steps)[
= [11] [VAR[名前]]を、第1引数を必須の [CODE(IDL)@en[DOMString]] として解釈した結果に設定します。
= [12] [[文脈オブジェクト]]が[F[名前][定義名]]が[VAR[名前]]の項目を含むなら、
== [13] [[文脈オブジェクト]]の[F[名前][定義名]]が[VAR[名前]]の項目の[F[構築器][カスタム要素構築器]]を返します。
= [14] それ以外なら、
== [15] [[未定義]]を返します。
]FIG]

[16] [[カスタム要素構築器]]に関わる各種処理の制限より、この[[メソッド]]が返すのは、
[[JavaScript]] の[[関数]]か [CODE(JS)@en[undefined]] のいずれかとなります。

* 歴史

[1] [CITE@en[Add custom elements to HTML · whatwg/html@6e7eaa4]]
([TIME[2016-04-26 18:17:34 +09:00]] 版)
<https://github.com/whatwg/html/commit/6e7eaa4bd2912965fd83766f99f984f249531f3a>

[2] [CITE@en[Add customElements.get() to retrieve a custom element constructor · whatwg/html@1d596a5]]
([TIME[2016-04-26 18:40:59 +09:00]] 版)
<https://github.com/whatwg/html/commit/1d596a555d3c2f067ae643e447eaa88137b595ac>

[17] [CITE@en[Handle reentrant custom element definition]]
([[domenic]]著, [TIME[2016-06-07 17:18:04 +09:00]])
<https://github.com/whatwg/html/commit/270b5f3e48411063c431fdf98dbe41766ddc20b1>

[18] [CITE@en[Rename "CustomElementsRegistry" to "CustomElementRegistry"]]
([[domenic]]著, [TIME[2016-08-24 15:33:08 +09:00]])
<https://github.com/whatwg/html/commit/9e38ff4c7921c63b07fb6e8f4e3cb88d84bd39c2>

[21] [CITE@en[Editorial: make the type of custom element constructors stricter]]
([[yuki3]]著, [TIME[2018-05-30 00:29:26 +09:00]])
<https://github.com/whatwg/html/commit/f8bd887aff17a5ffaf8c50c76b937815c92fc5e4>