/
466.txt
97 lines (73 loc) · 4.62 KB
/
466.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
[18] [CODE(DOMi)@en[[[Document]]]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[[[body]]]]]] [[IDL属性]]は、[[文書body要素]]を返します。
ほとんどの場合、 [CODE(JS)@en[[[document.body]]]] [[属性]]は
[CODE(HTMLe)@en[[[body]]]] [[要素]]を返すものです。
* 仕様書
[REFS[
- [3] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-05-06 10:42:35 +09:00]] 版) <https://html.spec.whatwg.org/#the-body-element-2>
- [24] [CITE@en[CSSOM View Module]] ([TIME[2016-08-06 08:18:46 +09:00]]) <https://drafts.csswg.org/cssom-view/#the-html-body-element>
]REFS]
* 意味
[4] [DFN[[RUBYB[文書body要素]@en[the body element]]]]は、
[[文書html要素]]の最初の [CODE(HTMLe)@en[[[body]]]] [[要素]]または
[CODE(HTMLe)@en[[[frameset]]]] [[要素]]である[[子供]]です。
そのような[[要素]]がなければ、 [[null]] です。 [SRC[>>3]]
;; [27] こちらの定義は、 [[HTML]] と [[DOM]] で使われています。
[25] [DFN[[RUBYB[HTML [CODE(HTMLe)@en[body]]要素]@en[the HTML [CODE(HTMLe)@en[body]] element]]]]は、
[[根要素]]である [CODE(HTMLe)@en[html]] [[要素]]の最初の [CODE(HTMLe)@en[body]]
[[要素]]の[[子供]]です。 [SRC[>>24]]
;; [26] こちらの定義は、 [[CSS]] で使われています。 [CODE(HTMLe)@en[frameset]]
[[要素]]は該当しません。
* 取得器
[5] [CODE(DOMi)@en[[[Document]]]] [[インターフェイス]]の
[CODE(DOMa)@en[[[body]]]] [[IDL属性]]の[[取得器]]は、
[[文書body要素]]を返さなければ[['''なりません''']] [SRC[>>3]]。
* 設定器
[6] [CODE(DOMi)@en[[[Document]]]] [[インターフェイス]]の
[CODE(DOMa)@en[[[body]]]] [[IDL属性]]の[[設定器]]は、
次のようにしなければ[['''なりません''']] [SRC[>>3]]。
[FIG(steps)[
= [7] 新しい値を [CODE(DOMi)@en[[[HTMLElement]][[?]]]] として解釈します。
= [8] 新しい値が [CODE(HTMLe)@en[[[body]]]] [[要素]]でも
[CODE(HTMLe)@en[[[frameset]]]] [[要素]]でもなければ、
== [9] [CODE(IDL)@en[[[HierarchyRequestError]]]] [[例外]]を[[投げ]]、ここで停止します。
= [10] 新しい値が[[文書body要素]]なら、
== [13] ここで停止します。
= [11] [[文書body要素]]が [[null]] 以外なら、
== [12] 新しい値で[[文書body要素]]を[[置換]]します。ここで停止します。
= [14] [[文書body要素]]が [[null]] なら、
== [15] [[根要素]]があれば、
=== [16] 新しい値を[[根要素]]に [[append]] します。
]FIG]
;; [17] [[根要素]]が[[文書html要素]]とは限りませんが、 [[append]]
しなければならないことになっています。
* 歴史
[1] [CITE@en[Web Applications 1.0 r7800 Match reality]]
( ([TIME[2013-04-11 07:00:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7799&to=7800>
[2] [CITE[IRC logs: freenode / #whatwg / 20130417]]
( ([TIME[2013-04-21 11:38:52 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20130417#l-1157>
* メモ
[19] [[構文解析器]]が [CODE(HTMLe)@en[[[body]]]] [[要素]]を[[文書に挿入]]する前に実行される[[スクリプト]]では、
[CODE(JS)@en[[[document.body]]]] は [[null]] になります。
[20] 今日では [CODE(HTMLe)@en[[[frameset]]]] [[要素]]はほとんど用いられることが無いため、
[[スクリプト]]は普通は [CODE(HTMLe)@en[[[body]]]] [[要素]]が返されるものと考えて構いません。
[21] [CITE@en[Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7]]
([TIME[2016-03-20 18:02:02 +09:00]] 版)
<https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd>
[22] [CITE@en[Formalize custom element reactions · whatwg/html@27aa7bc]]
([TIME[2016-04-26 18:51:29 +09:00]] 版)
<https://github.com/whatwg/html/commit/27aa7bc4fa6f168654a8c858f0773e611f679b39>
[23] [CITE@en[Specify how html and body elements fill the viewport]]
( ([[zcorpan]]著, [TIME[2016-05-04 00:43:01 +09:00]]))
<https://github.com/whatwg/quirks/commit/c81e2a263fb9f89fdfc55010afe666f1711540b7>
[28] [CITE@en[Call out inconsistency in document.body behavior]]
([[zcorpan]]著, [TIME[2018-02-13 01:20:09 +09:00]])
<https://github.com/whatwg/html/commit/aa2bec4ee4089f7e6329d3e285b6b5782ab3efc2>
[29] [CITE@en[How should document.body setter behave when root is not an `<html>`? · Issue #3403 · whatwg/html]]
([TIME[2018-02-13 14:29:40 +09:00]])
<https://github.com/whatwg/html/issues/3403>
[30] [CITE@en[Call out inconsistency in document.body behavior by zcorpan · Pull Request #3449 · whatwg/html]]
([TIME[2018-02-13 14:31:34 +09:00]])
<https://github.com/whatwg/html/pull/3449>