-
Notifications
You must be signed in to change notification settings - Fork 4
/
287.txt
161 lines (126 loc) · 7.93 KB
/
287.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
* 仕様書
[REFS[
- [13] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2016-11-02 16:40:24 +09:00]]) <https://html.spec.whatwg.org/#broadcasting-to-other-browsing-contexts>
]REFS]
* 文脈
[16] [CODE(DOMi)@en[BroadcastChannel]] [[インターフェイス]]は、[[文書環境]]と[[ワーカー環境]]に[[晒され]]ています
[SRC[>>13]]。
* 状態
[19] [CODE(DOMi)@en[BroadcastChannel]] [[オブジェクト]]は、
[CODE(DOMi)@en[EventTarget]] としての状態に加えて、
次の状態を持ちます。
[FIG(list members)[
: [F[通信路名]] :
[[文字列]]。
: [DFN[[F[[RUBYB[[[[CODE(DOMi)@en[BroadcastChannel]]設定群オブジェクト]]]@en[[CODE(DOMi)@en[BroadcastChannel]] settings object]]]]]] :
[[環境設定群オブジェクト]]。
: [F[閉じ済みフラグ]] :
[[ブール型]]。
初期値は[[偽]]。
]FIG]
* コンストラクター
[14] [CODE(DOMi)@en[BroadcastChannel]] [[コンストラクター]]は、
次のようにしなければ[MUST[なりません]] [SRC[>>13]]。
[FIG(steps)[
= [15] [VAR[名前]]を、必須の第1引数を [CODE(IDL)@en[DOMString]] と解釈した結果に設定します。
= [20] 新しい [CODE(DOMi)@en[BroadcastChannel]] [[オブジェクト]]を返します。
[FIG(list members)[ [21] [CODE(DOMi)@en[BroadcastChannel]]
: [F[通信路名]] : [VAR[名前]]
: [F[[[[CODE(DOMi)@en[BroadcastChannel]]設定群オブジェクト]]]] : [[現職設定群オブジェクト]]
]FIG]
]FIG]
* メンバー
[17] [CODE(DOMi)@en[BroadcastChannel]] [[インターフェイス]]は、
[CODE(DOMi)@en[EventTarget]] [[インターフェイス]]を[[継承]]しています [SRC[>>13]]。
[18] 加えて、次の[[メンバー][インターフェイスメンバー]]を持ちます。
[FIG(short list)[
- [CODE(DOMm)@en[close][BroadcastChannel]]
- [CODE(DOMa)@en[name][BroadcastChannel]]
- [CODE(DOMa)@en[onmessage]]
- [CODE(DOMm)@en[postMessage]]
]FIG]
* [CODE(DOMi)@en[BroadcastChannel]] インターフェイス [CODE(DOMa)@en[name][BroadcastChannel]] 属性
[22] [CODE(DOMi)@en[BroadcastChannel]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[name][BroadcastChannel]]]] [[IDL属性]]は、
次のようにしなければ[MUST[なりません]] [SRC[>>13]]。
[FIG(steps)[
= [23] [[文脈オブジェクト]]の[F[通信路名]]を返します。
]FIG]
[24] [CODE(DOMi)@en[BroadcastChannel]] [[オブジェクト]]は、
[DFN[[F[[RUBYB[[[通信路名]]]@en[channel name]]]]]]を持ちます [SRC[>>13]]。
[[コンストラクター]]で指定された値が設定されます。この値は以後変更されることはありません。
* [CODE(DOMi)@en[BroadcastChannel]] インターフェイス [CODE(DOMa)@en[close][BroadcastChannel]] 属性
[31] [CODE(DOMi)@en[BroadcastChannel]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[close][BroadcastChannel]]]] [[メソッド]]は、
次のようにしなければ[MUST[なりません]] [SRC[>>13]]。
[FIG(steps)[
= [32] [[文脈オブジェクト]]の[F[閉じ済みフラグ]]を、[[真]]に設定します。
= [34] [[文脈オブジェクト]]の [F[[CODE(DOMi)@en[BroadcastChannel]]設定群オブジェクト]]の[F[大域オブジェクト]]の[F[[CODE(DOMi)@en[BroadcastChannel]]群]]から、
[[文脈オブジェクト]]を削除します。
]FIG]
[33] [CODE(DOMi)@en[BroadcastChannel]] [[オブジェクト]]は、
[DFN[[F[[RUBYB[[[閉じ済みフラグ]]]@en[closed flag]]]]]]を持ちます [SRC[>>13]]。
初期値は[[偽]]です。
-*-*-
[25] [[大域オブジェクト]]は、[F[[CODE(DOMi)@en[BroadcastChannel]]群]]という[[集合]]を持ちます。
初期状態は空です。
[26] [CODE(DOMi)@en[BroadcastChannel]] [VAR[BC]] に[[イベントリスナー]]が追加され、
その[F[イベント型]]が [CODE(DOMe)@en[message][onmessage]] の場合、次のようにしなければ[MUST[なりません]]
[SRC[>>13]]。
[FIG(steps)[
= [27] [VAR[BC]] の[F[閉じ済みフラグ]]が[[偽]]なら、
== [28] [VAR[BC]] の [F[[CODE(DOMi)@en[BroadcastChannel]]設定群オブジェクト]]の[F[大域オブジェクト]]の[F[[CODE(DOMi)@en[BroadcastChannel]]群]]に、
[VAR[BC]] を追加します。
]FIG]
[29] [CODE(DOMi)@en[BroadcastChannel]] [VAR[BC]] から[F[イベント型]]が [CODE(DOMe)@en[message][onmessage]]
の[[イベントリスナー]]がすべて削除された場合、次のようにしなければ[MUST[なりません]]
[SRC[>>13]]。
[FIG(steps)[
= [30] [VAR[BC]] の [F[[CODE(DOMi)@en[BroadcastChannel]]設定群オブジェクト]]の[F[大域オブジェクト]]の[F[[CODE(DOMi)@en[BroadcastChannel]]群]]から、
[VAR[BC]] を削除します。
]FIG]
-*-*-
[35] [CODE(DOMi)@en[BroadcastChannel]] を作成して [CODE(DOMe)@en[message][onmessage]]
の[[イベントリスナー]]を登録すると、[[大域オブジェクト]]にも登録されることになります。
[[スクリプト]]から [CODE(DOMi)@en[BroadcastChannel]] への参照を削除しても、
(まだ[[イベントリスナー]]が呼び出される可能性が残るため)
[[大域オブジェクト]]からの参照は破棄されず、残ったままになります。
このため、必要がなくなったら明示的に [CODE(DOMm)(@en@[close][BroadcastChannel]]
[[メソッド]]を呼び出すことが[RUBYB[強く推奨]@en[strongly encouraged]]されています [SRC[>>13]]。
* 歴史
[1] [CITE@en[Web Applications 1.0 r8274 New BroadcastChannel feature to send messages to other tabs in the same origin, so you don't have to abuse the onstorage event, and don't need to use a heavy shared worker for something otherwise trivial.]]
( ([TIME[2013-11-14 04:09:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8273&to=8274>
[2] [CITE@en[Web Applications 1.0 r8450 Oops, forgot to make BroadcastChannel inherit from EventTarget]]
( ([TIME[2014-02-01 06:26:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8449&to=8450>
[3] [CITE[''''''[''''''whatwg'''''']'''''' BroadcastChannel should support structured clones]]
( ([TIME[2014-04-29 23:49:00 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-April/254182.html>
[4] [CITE@en[Web Applications 1.0 r8590 Make BroadcastChannel support structured clones]]
( ([TIME[2014-04-30 09:13:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8589&to=8590>
[5] [CITE@en[Web Applications 1.0 r8593 Change the sort order for broadcast channel messages to be easier to implement]]
( ([TIME[2014-05-02 02:58:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8592&to=8593>
[6] [CITE@en[Web Applications 1.0 r8660 Make BroadcastChannel objects work in workers]]
( ([TIME[2014-06-07 06:27:00 +09:00]] 版))
<http://html5.org/r/8660>
[7] [CITE@en[Re: ''''''[''''''whatwg'''''']'''''' BroadcastChannel memory leak]]
( ([[Ian Hickson]] 著, [TIME[2014-06-07 06:37:18 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Jun/0034.html>
[8] [CITE@en[Web Applications 1.0 r8661 Add BroadcastChannel.close()]]
( ([TIME[2014-06-07 06:38:00 +09:00]] 版))
<http://html5.org/r/8661>
[9] [CITE@en[966439 – Implement BroadcastChannel API]]
( ([TIME[2015-01-14 22:17:47 +09:00]] 版))
<https://bugzilla.mozilla.org/show_bug.cgi?id=966439>
[10] [CITE@en[Reduce the number of terms BroadcastChannel introductory text uses · whatwg/html@f363b95]]
([TIME[2015-09-02 16:39:04 +09:00]] 版)
<https://github.com/whatwg/html/commit/f363b9585a7d48c67f0b06895545db588d093ce8>
[11] [CITE@en[Clarify settings object, realm, and global relationships · whatwg/html@0866f1b]]
([TIME[2016-03-28 00:39:21 +09:00]] 版)
<https://github.com/whatwg/html/commit/0866f1b3f4b4ea5a99a30909e9bbe557dea0b460>
[12] [CITE@en[Chromium Blog: Chrome 54 Beta: Custom Elements V1, BroadcastChannel, and media platform improvements]]
( ([TIME[2016-09-17 08:54:54 +09:00]]))
<https://blog.chromium.org/2016/09/chrome-54-beta-custom-elements-v1.html>