4.11. 対話的な要素
【この訳に特有な表記規約】
この訳において(主にアルゴリズム内で)利用される各種記号( ε, ← , IF, THROW, 等々)の意味や定義の詳細は、共通な慣用表現, アルゴリズムに共通して利用される表記を参照されたし。
4.11.1. details
要素
- 分類
- フロー内容/対話的内容/可触内容 Flow content.Interactive content.Palpable content.
- この要素を利用できる文脈
- フロー内容が期待される所。 Where flow content is expected.
- 内容モデル
-
[
1 個の
summary
要素, フロー内容 ]からなる並び One summary element followed by flow content. - text/html におけるタグ省略
- 両タグとも省略不可。 Neither tag is omissible.
- 内容属性
- 大域属性 Global attributes
-
name
— 互いに排他的なdetails
要素たちが成すグループの名前 name — Name of group of mutually-exclusive details elements -
open
— 詳細は可視であるかどうか open — Whether the details are visible - アクセス能の考慮点
- 作者向け/実装者向け For authors. For implementers.
- DOM インタフェース
-
[Exposed=Window] interface
HTMLDetailsElement
:HTMLElement
{ [HTMLConstructor] constructor(); [CEReactions] attribute DOMStringname
; [CEReactions] attribute booleanopen
; };
details
要素は、
利用者が追加の情報やコントロールを得れるような,開閉式ウィジェットを表現する。
The details element represents a disclosure widget from which the user can obtain additional information or controls.
注記:
他の HTML 要素と同じく、
details
要素を利用して別の型のコントロールを表現するよう試みることは,
適合でない。
例えば,タブウィジェットやメニューウィジェットは、
開閉式ウィジェットではないので,
そのようなパタンを実装するために details
要素を濫用することは不正である。
As with all HTML elements, it is not conforming to use the details element when attempting to represent another type of control. For example, tab widgets and menu widgets are not disclosure widgets, so abusing the details element to implement these patterns is incorrect.
注記:
details
要素は、
脚注等( footnote )には適切でない。
脚注をマークアップする方法の詳細は、
脚注に関する節を見られたし。
The details element is not appropriate for footnotes. Please see the section on footnotes for details on how to mark up footnotes.
要素の最初の子が summary
要素であるならば、
それが詳細の[
要約( summary ) / legend
]を表現する。
そのような子がなければ、
UA は,自前の legend (例: “詳細” )を供するべきである。
The first summary element child of the element, if any, represents the summary or legend of the details. If there is no child summary element, the user agent should provide its own legend (e.g. "Details").
要素の残りの内容は、 追加の[ 情報やコントロールたち ]を表現する。 The rest of the element's contents represents the additional information or controls.
name
内容属性は、
互いに関係する details
要素たちが成すグループの名前を与える。
このグループを成す あるメンバを開くと、
他のメンバは閉じられる。
この属性に指定する値は、
空文字列にしてはならない。
The name content attribute gives the name of the group of related details elements that the element is a member of. Opening one member of this group causes other members of the group to close. If the attribute is specified, its value must not be the empty string.
作者は、
この特能を利用する前に,[
互いに関係する details
要素たちを排他的なアコーディオン【蛇腹の様な UI 】の中へグループ化すること
]が[
利用者にとって助けになるか有害になるか
]を考慮するべきである。
排他的なアコーディオンを利用すれば,それら一連の内容が占める空間の最大な量を抑制できるが、[
求めるものを見出すために多くのアイテムを開く必要がある/
複数のアイテムの内容を同時に調べたいと求める
]利用者をいらつかせかねない。
Before using this feature, authors should consider whether this grouping of related details elements into an exclusive accordion is helpful or harmful to users. While using an exclusive accordion can reduce the maximum amount of space that a set of content can occupy, it can also frustrate users who have to open many items to find what they want or users who want to look at the contents of multiple items at the same time.
文書は、
同じ有名 details グループ内に open
属性を有する複数個の details
要素を包含してはならない。
作者は、
スクリプトを利用して,そのようになるよう文書に details
要素を追加してはならない。
A document must not contain more than one details element in the same details name group that has the open attribute present. Authors must not use script to add details elements to a document in a way that would cause a details name group to have more than one details element with the open attribute present.
注記:
共通な name
属性により作成される要素たちが成すグループは、
排他的である
— すなわち、
同時に開かれ得る details
要素は 1 個しかないことを意味する。
この排他性は,UA により施行されるが、
その結果の施行は,
マークアップ内の open
属性を即時に変更する。
作者に対するこの要件は、
そのような紛らわしいマークアップを禁止する。
The group of elements that is created by a common name attribute is exclusive, meaning that at most one of the details elements can be open at once. While this exclusivity is enforced by user agents, the resulting enforcement immediately changes the open attributes in the markup. This requirement on authors forbids such misleading markup.
文書は、
次を満たす details
要素を包含してはならない
:同じ有名 details グループに属する別の details
要素の子孫である
A document must not contain a details element that is a descendant of another details element in the same details name group.
name
属性を利用して[
互いに関係する複数個の details
要素
]をグループ化する文書は、
それらを一緒に保つよう,ある要素( section
や article
など)内に包含するべきである。
グループを見出しと伴に導入することが意味を成すときは、
作者は,[
当の details
要素たちを包含している要素
]の始端に見出し用の要素を与えて,その中に当の見出しを置くべきである。
Documents that use the name attribute to group multiple related details elements should keep those related elements together in a containing element (such as a section element or article element). When it makes sense for the group to be introduced with a heading, authors should put that heading in a heading element at the start of the containing element.
注記: 関係する要素たちを[ 視覚的/プログラム的 ]に一緒にグループ化することは、 アクセス可能な利用者体験のために重要になり得る。 そうすれば、 利用者が,そのような要素どうしの関係性を理解し易くなり得る。 関係する要素たちがグループ化されず,web ページを成す異質な複数の節内にあると、 要素どうしの関係性は,[ 発見し難く/理解し難く ]なり得る。 Visually and programmatically grouping related elements together can be important for accessible user experiences. This can help users understand the relationship between such elements. When related elements are in disparate sections of a web page rather than being grouped, the elements' relationships to each other can be less discoverable or understandable.
open
内容属性は真偽属性である。
在る場合、[
要約, 追加の情報どちらも利用者に示す
]ことを指示する。
無い場合、
要約のみが示される。
The open content attribute is a boolean attribute. If present, it indicates that both the summary and the additional information is to be shown to the user. If the attribute is absent, only the summary is to be shown.
追加の情報は、 要素の作成時には,この属性が[ 無いならば 隠される / 在るならば 示される ]べきである。 その後に,属性が[ 除去された/追加された ]場合、 情報は[ 隠される/示される ]べきである。 When the element is created, if the attribute is absent, the additional information should be hidden; if the attribute is present, that information should be shown. Subsequently, if the attribute is removed, then the information should be hidden; if the attribute is added, the information should be shown.
UA は、[ 要素 要素 に対し,追加の情報を[ 示す/隠す ]よう要請する ]ことを利用者に許容するべきである。 そのような要請を尊守するときは、 UA は,次を走らすものとする:
The user agent should allow the user to request that the additional information be shown or hidden. To honor a request for the details to be shown, the user agent must set the open attribute on the element to the empty string. To honor a request for the information to be hidden, the user agent must remove the open attribute from the element.
この,追加の情報を[
示す/隠す
]能は、
適切な summary
要素が存在するならば,単純に その作動化のふるまいになり得る。
しかしながら,そのような要素が存在しない場合でも、
UA は,何らかの他の UI affordance を通して この能を供せる。
This ability to request that additional information be shown or hidden may simply be the activation behavior of the appropriate summary element, in the case such an element exists. However, if no such element exists, user agents can still provide this ability through some other user interface affordance.
各
有名 details グループ
は、
ある details
要素 a を包含するならば,
他の details
要素 b のうち ∧↓ を満たすものすべてを包含する:
The details name group that contains a details element a also contains all the other details elements b that fulfill all of the following conditions:
- a, b は同じ ツリー内にある Both a and b are in the same tree.
-
a, b どちらも
name
属性を有していて,それらの値は等しい かつ空文字列でない They both have a name attribute, their name attributes are not the empty string, and the value of a's name attribute equals the value of b's name attribute.
各 details
要素は、
details 用のトグルタスク追跡子
を有する
— それは、[
null /トグルタスク追跡子
]であり,
初期時は null とする。
Every details element has a details toggle task tracker, which is a toggle task tracker or null, initially null.
details
要素 要素 用に利用される属性変更時の手続きは、
所与の
( 局所名, 旧値, 値, 名前空間 )
に対し:
The following attribute change steps, given element, localName, oldValue, value, and namespace, are used for all details elements:
- IF[ 名前空間 ≠ null ] :RETURN If namespace is not null, then return.
-
IF[
局所名 = "
name
" ] :必要なら要素を閉じることにより details の排他性を確保する( 要素, 自身 ) If localName is name, then ensure details exclusivity by closing the given element if needed given element. -
IF[ 局所名 = "
open
" ]: If localName is open, then:-
IF[ 旧値 ≠ 値 ]∧[ null ∈ { 旧値, 値 } ]: If one of oldValue or value is null and the other is not null, run the following steps,\
この段を成す手続きは、 要素 用の details 通知タスク手続き と称される。 which are known as the details notification task steps, for this details element:
注記:
open
属性が何回か続けてトグルされたときは、 結果のタスクは,本質的にイベントが 1 回だけ発火されるよう合体される。 When the open attribute is toggled several times in succession, the resulting tasks essentially get coalesced so that only one event is fired.-
IF[
旧値 = null
]
:details 用のトグルイベントタスクをキューする( 要素, "
closed
", "open
" ) If oldValue is null, queue a details toggle event task given the details element, "closed", and "open". -
ELSE
:details 用のトグルイベントタスクをキューする( 要素, "
open
", "closed
" ) Otherwise, queue a details toggle event task given the details element, "open", and "closed".
-
IF[
旧値 = null
]
:details 用のトグルイベントタスクをキューする( 要素, "
- IF[ 旧値 = null ]∧[ 値 ≠ null ] :必要なら要素を閉じることにより details の排他性を確保する( 要素, 他の要素 ) If oldValue is null and value is not null, then ensure details exclusivity by closing other elements if needed given element.
-
details
用の HTML 要素挿入時の手続きは、
所与の
( 挿入されるノード )
に対し:
The details HTML element insertion steps, given insertedNode, are:
- 必要なら要素を閉じることにより details の排他性を確保する( 挿入されるノード, 自身 ) Ensure details exclusivity by closing the given element if needed given insertedNode.
注記: (念のため、) これらの属性[ 属性変更時の手続き/属性挿入時の手続き ]は、 属性や要素が構文解析器を介して挿入されるときにも走る。 To be clear, these attribute change and insertion steps also run when an attribute or element is inserted via the parser.
details 用のトグルイベントタスクをキューする
アルゴリズムは、
所与の
( details
要素 要素, 文字列 旧状態, 文字列 新状態 )
に対し:
To queue a details toggle event task given a details element element, a string oldState, and a string newState:
- 追跡子 :← 要素 の details 用のトグルタスク追跡子 ↓
-
IF[ 追跡子 ≠ null ]: If element's details toggle task tracker is not null, then:
- 旧状態 ← 追跡子 の旧状態 Set oldState to element's details toggle task tracker's old state.
- 追跡子 のタスクを それが属するタスクキューから除去する Remove element's details toggle task tracker's task from its task queue.
- 要素 の details 用のトグルタスク追跡子 ← null Set element's details toggle task tracker to null.
-
タスク :← 要素タスクをキューする( DOM 操作タスクソース, 要素, 次の手続き ) Queue an element task given the DOM manipulation task source and element to run\
手続きは: the following steps:
-
イベントを発火する( 要素,
toggle
,ToggleEvent
) — 次のように初期化して :oldState
属性 ← 旧状態,newState
属性 ← 新状態 Fire an event named toggle at element, using ToggleEvent, with the oldState attribute initialized to oldState and the newState attribute initialized to newState. - 要素 の details 用のトグルタスク追跡子 ← null Set element's details toggle task tracker to null.
-
イベントを発火する( 要素,
- 要素 の details 用のトグルタスク追跡子 ← 次を伴う構造体 :タスク ← タスク, 旧状態 ← 旧状態 Set element's details toggle task tracker to a struct with task set to the just-queued task and old state set to oldState.
必要なら要素を閉じることにより details の排他性を確保する
アルゴリズムは、
所与の
( details
要素 要素, 対象 ∈ {
自身,
他の要素
} )
に対し:
【 このアルゴリズムは、 原文では 2 つのアルゴリズムにより定義されているが, この訳では 対象 フラグを通して 1 つに集約する。 】
-
IF[
対象 = 自身
]
:Assert:
要素 は
open
属性を有する -
ELSE IF[
要素 は
open
属性を有さない ] :RETURN -
IF[
要素 は
name
属性を有さない ]∨[ 要素 はname
属性を有していて,その値 = 空文字列 ] :RETURN - 閉じる必要がある要素 :← ε
-
要素 が属する有名 details グループを成す 各( 他の要素 ) に対し,ツリー順序で:
- IF[ 他の要素 = 要素 ] :CONTINUE
-
IF[
他の要素 は
open
属性を有さない ] :CONTINUE -
Assert: 要素 が属する有名 details グループを成すメンバのうち 要素, 他の要素 以外のものは
open
属性を有さない。【 この表明は、 原文では 対象 = 他の要素 の場合に限り与えられているが, 対象 を問わず満たされるはずである。 】
- 閉じる必要がある要素 :← 対象 に応じて :他の要素 ならば 他の要素 / 自身 ならば 要素 /
- BREAK
-
IF[
閉じる必要がある要素 ≠ ε
]
:閉じる必要がある要素 から
open
属性を除去する
name
IDL 属性は、
name
内容属性を反映するものとする。
open
IDL 属性は、
open
内容属性を反映するものとする。
先祖 details を露わにする アルゴリズムは、 所与の ( 現在のノード ) に対し: The ancestor details revealing algorithm is to run the following steps on currentNode:
-
WHILE [ 現在のノード は平坦ツリーの中で親ノードを有する ]: While currentNode has a parent node within the flat tree:
details
要素を利用して,進捗報告内の技術的な詳細を隠す例:
The following example shows the details element being used to hide technical details in a progress report.
<section class="progress window"> <h1>"Really Achieving Your Childhood Dreams" を複製しています</h1> <details> <summary>複製中... <progress max="375505392" value="97543282"></progress> 25%</summary> <dl> <dt>転送レート: </dt> <dd>452KB/s</dd> <dt>保存先: </dt> <dd>/home/rpausch/raycd.m4v</dd> <dt>転送元: </dt> <dd>/var/www/lectures/raycd.m4v</dd> <dt>経過時間: </dt> <dd>01:16:27</dd> <dt>色プロファイル: </dt> <dd>SD (6-1-6)</dd> <dt>サイズ: </dt> <dd>320×240</dd> </dl> </details> </section>
details
要素を利用して,コントロールを既定で隠す例:
The following shows how a details element can be used to hide some controls by default:
<details> <summary><label for=fn>名前と拡張子:</label></summary> <p><input type=text id=fn name=fn value="Pillar Magazine.pdf"> <p><label><input type=checkbox name=ext checked>拡張子を隠す</label> </details>
これを リスト内で他の details
と併用すれば、[
それぞれが展開する能を伴う一群のフィールドを,一群の見出しに小さく縮約する
]ことを利用者に許容することもできる。
One could use this in conjunction with other details in a list to allow the user to collapse a set of fields down to a small set of headings, with the ability to open each one.


これらの例における summary
(要約)が要約する( summarize する)ものは,
コントロールが何を変更できるかだけであり、
実際の値まで示すのは,理想とは言えない。
In these examples, the summary really just summarizes what the controls can change, and not the actual values, which is less than ideal.
details
要素の name
属性を利用して,
details
要素たちが成す排他的なアコーディオンを作成する例
— そこでは、
ある details
要素を開く利用者による動作により,他の開かれた details
は閉じられる。
The following example shows the name attribute of the details element being used to create an exclusive accordion, a set of details elements where a user action to open one details element causes any open details to close.
<section class="characteristics"> <details name="frame-characteristics"> <summary>素材</summary> この額縁は、無垢なオーク材でできています。 </details> <details name="frame-characteristics"> <summary>Size</summary> 額縁には、高さ 40cm, 幅 30cm の写真が収まります。 額縁自体は、高さ 45cm, 幅 35cm, 太さ 2cm です。 </details> <details name="frame-characteristics"> <summary>色</summary> この額縁には、 自然な木目に着色されたもの, 黒に着色されたものがあります。 </details> </section>
次の例は、[
name
属性を利用して作成された details
要素たちが成す排他的なアコーディオン
]において,ある details
要素に open
属性が設定されたとき、
何が起こるかを示す。
The following example shows what happens when the open attribute is set on a details element that is part of a set of elements using the name attribute to create an exclusive accordion.
次の初期マークアップ: Given the initial markup:
<section class="characteristics"> <details name="frame-characteristics" id="d1" open>...</details> <details name="frame-characteristics" id="d2">...</details> <details name="frame-characteristics" id="d3">...</details> </section>
および次のスクリプト: and the script:
document.getElementById("d2").setAttribute("open", "");
が与えられた下で,当のスクリプトを実行した後における結果のツリーは、 次のマークアップと等価になる: then the resulting tree after the script executes will be equivalent to the markup:
<section class="characteristics"> <details name="frame-characteristics" id="d1">...</details> <details name="frame-characteristics" id="d2" open>...</details> <details name="frame-characteristics" id="d3">...</details> </section>
"d2
" を伴う要素の open
属性が設定されたので、
"d1
" を伴う要素のそれは除去される。
because setting the open attribute on d2 removes it from d1.
同じことは、
利用者が "d2
" を伴う要素の内側にある summary
要素を作動化したときにも起こる。
The same happens when the user activates the summary element inside of d2.
open
属性は、
利用者がコントロールとやりとりするに伴って,自動的に[
追加/除去
]されるので、
その状態に基づいて,CSS 内で要素に異なるスタイルをあてがうことに利用できる。
ここでは、
要素が[
展開された/畳まれた
]とき,要約の色をアニメートするスタイルシートの例を示す:
Because the open attribute is added and removed automatically as the user interacts with the control, it can be used in CSS to style the element differently based on its state. Here, a style sheet is used to animate the color of the summary when the element is opened or closed:
<style> details > summary { transition: color 1s; color: black; } details[open] > summary { color: red; } </style> <details> <summary>自動運転: 作動中</summary> <p>速度: 12m/s</p> <p>方向: 北</p> </details>
4.11.2. summary
要素
- 分類
- なし。 None.
- この要素を利用できる文脈
-
details
要素の最初の子として。 As the first child of a details element. - 内容モデル
- 句内容。 加えて,見出し内容が混在していてもよい。 Phrasing content, optionally intermixed with heading content.
- text/html におけるタグ省略
- 両タグとも省略不可。 Neither tag is omissible.
- 内容属性
- 大域属性 Global attributes
- アクセス能の考慮点
- 作者向け/実装者向け For authors. For implementers.
- DOM インタフェース
-
HTMLElement
を利用する。 Uses HTMLElement.
summary
要素は、
その親が details
要素であれば,親の他の内容に対する[
要約 / キャプション /legend
]を表現する。
The summary element represents a summary, caption, or legend for the rest of the contents of the summary element's parent details element, if any.
次を満たす要素は
親 details 用の summary
であるとされる
:[
summary
要素である
]∧[
親は details
要素である
]∧[
先行する同胞に別の summary
要素は無い
]
A summary element is a summary for its parent details if the following algorithm returns true:
• If this summary element has no parent, then return false.
• Let parent be this summary element's parent.
• If parent is not a details element, then return false.
• If parent's first summary element child is not this summary element, then return false.
• Return true.
summary
要素 要素 の作動化のふるまいは:
The activation behavior of summary elements is to run the following steps:
- IF[ 要素 は親 details 用の summary でない ] :RETURN If this summary element is not the summary for its parent details, then return.
- 親 :← 要素 の親 Let parent be this summary element's parent.
-
IF[
親 は
open
属性を有する ] :親 からopen
属性を除去する† If the open attribute is present on parent, then remove it.\ -
ELSE
:親 の属性値を設定する( "
open
", 空文字列 )† Otherwise, set parent's open attribute to the empty string.
注記†: これは、 details 通知タスク手続きを走らすことになる。 This will then run the details notification task steps.
4.11.3. コマンド
4.11.3.1. 側面
コマンド とは、[ メニューアイテム/ボタン/リンク ]の背後にある抽象化である。 コマンドが定義されたなら、 UI の他の各部は同じコマンドを指せるようになり,[ 不能化されるかなどの各種側面からなる単独の特能 ]に複数箇所からアクセスすることを許容する。 A command is the abstraction behind menu items, buttons, and links. Once a command is defined, other parts of the interface can refer to the same command, allowing many access points to a single feature to share facets such as the Disabled State.
各コマンド コマンド は、 次に挙げる 側面 ( facet )を有するように定義される: Commands are defined to have the following facets:
- ラベル Label
- 利用者から見える[ コマンド の名前 ]。 The name of the command as seen by the user.
- アクセスキー Access Key
- UA により選定される[ コマンド を誘発するキーの組み合せ ]または, ε (無し)。 A key combination selected by the user agent that triggers the command. A command might not have an Access Key.
- 隠されるか Hidden State
- 真偽値 — true ならば、 コマンド は隠される (基本的に,メニュー内に示されるべきかどうかを表す)。 Whether the command is hidden or not (basically, whether it should be shown in menus).
- 不能化されるか Disabled State
- 真偽値 — true ならば、 コマンド は関連しないので誘発できない。 Whether the command is relevant and can be triggered or not.
- 動作 Action
- コマンド を誘発したとき実際に生じる効果。 これは、 次に挙げるものなどになり得る :スクリプトによるイベントハンドラ / ナビゲート先の URL / フォーム提出 The actual effect that triggering the command will have. This could be a scripted event handler, a URL to which to navigate, or a form submission.
UA は、 ∧↓ が満たされるならば, 要素 要素 が定義するコマンドを公開してもよい : User agents may expose the commands that match the following criteria:
- 当のコマンドの隠されるか = false ( 要素 は可視である) The Hidden State facet is false (visible)
- [ 要素 はある文書内にある ]∧[ 当の文書が属する閲覧文脈 ≠ null ] The element is in a document with a non-null browsing context.
-
要素 の広義先祖として,
hidden
属性を有するものは無い Neither the element nor any of its ancestors has a hidden attribute specified.
UA には、 これを行うことが奨励される — とりわけアクセスキーを有するコマンド用に, それらのキーを利用者に告知する仕方として。 User agents are encouraged to do this especially for commands that have Access Keys, as a way to advertise those keys to the user.
例えば、 そのようなコマンドを[ UA のメニューバー内にリストする ]こともできる。 For example, such commands could be listed in the user agent's menu bar.
4.11.3.2. a
要素を利用してコマンドを定義する
a
要素 要素 は、
href
属性を有するならば,コマンドを定義する。
このコマンドの各種側面は:
An a element with an href attribute defines a command.
- ラベル
- 要素 の子孫テキスト内容 The Label of the command is the element's descendant text content.
- アクセスキー
- 要素 にあてがわれたアクセスキー — 無い場合は ε The Access Key of the command is the element's assigned access key, if any.
- 隠されるか
-
IS[
要素 は
hidden
属性を有する ] The Hidden State of the command is true (hidden) if the element has a hidden attribute, and false otherwise. - 不能化されるか
- IS[ 要素 の広義先祖として,不活なものが在る ] The Disabled State facet of the command is true if the element or one of its ancestors is inert, and false otherwise.
- 動作
- 要素 に向けてクリックイベントを発火する The Action of the command is to fire a click event at the element.
4.11.3.4. input
要素を利用してコマンドを定義する
input
要素 要素 は、[
その type
属性の状態 ∈
{ Submit, Reset, Image, Button, Radio, Checkbox }
]ならば,コマンドを定義する。
このコマンドの各種側面は:
An input element whose type attribute is in one of the Submit Button, Reset Button, Image Button, Button, Radio Button, or Checkbox states defines a command.
- ラベル
-
次に従って決定される: The Label of the command is determined as follows:
-
value :← [
要素 は
value
属性を有するならば その値 / 他の場合は ε ] ↓ -
IF[ 要素 の
type
属性の状態 ∈ { Submit, Reset, Image, Button } ]:- IF[ value ≠ ε ] :RETURN value
- RETURN UA がボタンに既定のラベルをあてがうときに利用する値 — 値は UA , およびロケールに依存する
-
IF[
要素 をラベル先コントロールとする
label
要素は在る ] :RETURN 該当するもののうち,ツリー順序で最初のものの子孫テキスト内容 (JavaScript で言えば, 要素.labels[0].textContent
) Otherwise, if the element is a labeled control, then the Label is the descendant text content of the first label element in tree order whose labeled control is the element in question. (In JavaScript terms, this is given by element.labels[0].textContent.) - RETURN value に応じて :ε ならば 空文字列 / 他の場合は value Otherwise, if the value attribute is present, then the Label is the value of that attribute.Otherwise, the Label is the empty string.
-
value :← [
要素 は
- 注記:
要素 が Image 状態にある場合,
value
属性は適合でないが、 要素 にalt
属性が欠落している場合には,依然としてラベルの決定に寄与する。 Even though the value attribute on input elements in the Image Button state is non-conformant, the attribute can still contribute to the Label determination, if it is present and the Image Button's alt attribute is missing. - アクセスキー
- 要素 にあてがわれたアクセスキー — 無い場合は ε The Access Key of the command is the element's assigned access key, if any.
- 隠されるか
-
IS[
要素 は
hidden
属性を有する ] The Hidden State of the command is true (hidden) if the element has a hidden attribute, and false otherwise. - 不能化されるか
- IS[ 要素 の広義先祖として,不活なものが在る ]∨[ 要素 は不能化されている ] The Disabled State of the command is true if the element or one of its ancestors is inert, or if the element's disabled state is set, and false otherwise.
- 動作
- 要素 に向けてクリックイベントを発火する The Action of the command is to fire a click event at the element.
4.11.3.5. option
要素を利用してコマンドを定義する
option
要素 要素 は、
∧↓ を満たすならば,コマンドを定義する:
- ラベル
-
要素 は
label
属性を有するならば その値/ 他の場合は 次の結果 :ASCII 空白を剥いで縮約する( 要素 の子孫テキスト内容 ) The Label of the command is the value of the option element's label attribute, if there is one, or else the option element's descendant text content, with ASCII whitespace stripped and collapsed. - アクセスキー
- 要素 にあてがわれたアクセスキー — 無い場合は ε The Access Key of the command is the element's assigned access key, if any.
- 隠されるか
-
IS[
要素 は
hidden
属性を有する ] The Hidden State of the command is true (hidden) if the element has a hidden attribute, and false otherwise. - 不能化されるか
-
IS ∨↓:
The Disabled State of the command is true if the element is disabled, or if its nearest ancestor select element is disabled, or if it or one of its ancestors is inert, and false otherwise. - 動作
-
次の手続きを走らす:
If the option's nearest ancestor select element has a multiple attribute, the Action of the command is to toggle the option element. Otherwise, the Action is to pick the option element.
4.11.3.6. legend
要素の accesskey
属性を利用してコマンドを定義する
legend
要素 要素 は、
∧↓ を満たすならば,コマンドを定義する:
A legend element defines a command if all of the following are true:
- あてがわれたアクセスキーはある It has an assigned access key.
-
要素 の親は
fieldset
要素である It is a child of a fieldset element. -
∧↓ を満たす要素は在る:
Its parent has a descendant that defines a command that is neither a label element nor a legend element.\該当する要素を指して、 当の
legend
要素の アクセスキー委任先 という。 This element, if it exists, is the legend element's accesskey delegatee.【 該当する要素が複数ある場合、 ツリー順序で最初のものになろう (以下の記述は、 一つしかないことを前提に記されている。 この節が更新される前も, “ツリー順序で最初” と記されていた。) 】
- ラベル
- 要素 の子孫テキスト内容 The Label of the command is the element's descendant text content.
- アクセスキー
- 要素 にあてがわれたアクセスキー — 無い場合は ε The Access Key of the command is the element's assigned access key.
- 隠されるか
- 不能化されるか
- 動作
-
それぞれ、
legend
要素 のアクセスキー委任先の対応する側面と同じになる。 The Hidden State, Disabled State, and Action facets of the command are the same as the respective facets of the legend element's accesskey delegatee.
この例では、
当の legend
要素には accesskey
が指定されている
— 要素が作動化されたときは、
その内側にある input
要素に委任することになる。
In this example, the legend element specifies an accesskey, which, when activated, will delegate to the input element inside the legend element.
<fieldset> <legend accesskey=p> <label><input name=pizza type=number step=1 value=1 min=0> 3 種のトッピング付きのピザを希望します </label> </legend> <label><input name=pizza-cheese type=checkbox checked>チーズ</label> <label><input name=pizza-ham type=checkbox checked>ハム</label> <label><input name=pizza-pineapple type=checkbox> パイナップル</label> </fieldset>
4.11.3.7. 他の要素上で accesskey
属性を利用してコマンドを定義する
要素 要素 は、 あてがわれたアクセスキーがあるならば,コマンドを定義する — ただし,これまでのいずれかの節にて[ 要素 はコマンドを定義するものと定義される ]ならば、 その節の規則が 要素 に適用される。 この節が適用されるのは、 他の場合に限られる。 An element that has an assigned access key defines a command.If one of the earlier sections that define elements that define commands define that this element defines a command, then that section applies to this element, and this section does not. Otherwise, this section applies to that element.
- ラベル
-
要素 をラベル先コントロールとする
label
要素は在るならば、[ 該当するもののうち,ツリー順序で最初のもの ]の子孫テキスト内容 (JavaScript で言えば, 要素.labels[0].textContent
) The Label of the command depends on the element. If the element is a labeled control, the descendant text content of the first label element in tree order whose labeled control is the element in question is the Label (in JavaScript terms, this is given by element.labels[0].textContent).\ - 他の場合、 要素 の子孫テキスト内容 Otherwise, the Label is the element's descendant text content.
- アクセスキー
- 要素 にあてがわれたアクセスキー The Access Key of the command is the element's assigned access key.
- 隠されるか
-
IS[
要素 は
hidden
属性を有する ] The Hidden State of the command is true (hidden) if the element has a hidden attribute, and false otherwise. - 不能化されるか
- IS[ 要素 の広義先祖として,不活なものが在る ] The Disabled State of the command is true if the element or one of its ancestors is inert, and false otherwise.
- 動作
-
次の手続きを走らす: The Action of the command is to run the following steps:
- オブジェクトをフォーカスする( 要素 ) Run the focusing steps for the element.
- 要素 に向けてクリックイベントを発火する Fire a click event at the element.
4.11.4. dialog
要素
- 分類
- フロー内容 Flow content.
- この要素を利用できる文脈
- フロー内容が期待される所。 Where flow content is expected.
- 内容モデル
- フロー内容 Flow content.
- text/html におけるタグ省略
- 両タグとも省略不可。 Neither tag is omissible.
- 内容属性
- 大域属性 Global attributes
-
closedby
— どの利用者動作が当のダイアログを閉じることになるか closedby — Which user actions will close the dialog -
open
— 当のダイアログボックスを示しているかどうか open — Whether the dialog box is showing - アクセス能の考慮点
- 作者向け/実装者向け For authors. For implementers.
- DOM インタフェース
-
[Exposed=Window] interface
HTMLDialogElement
:HTMLElement
{ [HTMLConstructor] constructor(); [CEReactions] attribute booleanopen
; attribute DOMStringreturnValue
; [CEReactions] attribute DOMStringclosedBy
; [CEReactions] undefinedshow
(); [CEReactions] undefinedshowModal
(); [CEReactions] undefinedclose
(optional DOMString returnValue); [CEReactions] undefinedrequestClose
(optional DOMString returnValue); };
dialog
要素は、[
あるタスクを遂行する/
情報を集める
]ために利用者がやりとりする小さなウィンドウ( “ダイアログボックス” )の形で,
アプリを成す一過性な部分を表現する。
利用者が それを済ませたなら、
当のダイアログは,アプリにより自動的に閉じられるか利用者により手動で閉じられる。
The dialog element represents a transitory part of an application, in the form of a small window ("dialog box"), which the user interacts with to perform a task or gather information. Once the user is done, the dialog can be automatically closed by the application, or manually closed by the user.
とりわけ,モーダルなダイアログ用には (それは、 どのアプリにも馴染みなパタンである)、 作者は,[ 自身の web アプリにおけるダイアログは、 非 web アプリの利用者にも馴染みな仕方でふるまう ]ことを確保するよう作業するべきである。 Especially for modal dialogs, which are a familiar pattern across all types of applications, authors should work to ensure that dialogs in their web applications behave in a way that is familiar to users of non-web applications.
注記:
dialog
要素を利用して,別の型のコントロールを表現するよう試みることは、
すべての HTML 要素と同じく,適合でない。
例えば,[
文脈メニュー/
ツールチップ/
ポップアップリストボックス
]は、
ダイアログボックスではないので,
これらのパタンを dialog
要素を濫用して実装することは不正になる。
As with all HTML elements, it is not conforming to use the dialog element when attempting to represent another type of control. For example, context menus, tooltips, and popup listboxes are not dialog boxes, so abusing the dialog element to implement these patterns is incorrect.
ダイアログにて利用者が直面するふるまいを成す重要な部分は、
初期フォーカスをどこに配置するかである。
ダイアログをフォーカスする手続きは,[
ダイアログが示されるとき,初期フォーカス用に良い候補を選ぶよう試みる
]が、
作者が[
特定のダイアログ用に,
利用者の期待に合致する正しいフォーカス先は どれなのか
]を注意深く考えているときには,その用を成さないかもしれない。
そのようなわけで、
作者は,当のダイアログの子孫要素のうち[
利用者が当のダイアログを開いた直後にやりとりすると期待されるもの
]に autofocus
属性を利用するべきである
— そのような要素が無い場合、
dialog
要素自身に autofocus
属性を利用するべきである。
An important part of user-facing dialog behavior is the placement of initial focus. The dialog focusing steps attempt to pick a good candidate for initial focus when a dialog is shown, but might not be a substitute for authors carefully thinking through the correct choice to match user expectations for a specific dialog. As such, authors should use the autofocus attribute on the descendant element of the dialog that the user is expected to immediately interact with after the dialog opens. If there is no such element, then authors should use the autofocus attribute on the dialog element itself.
次の例では、[ ある在庫管理 web アプリにおいて,ある製品の詳細を編集する ]ためとして,ダイアログが利用される: In the following example, a dialog is used for editing the details of a product in an inventory management web application.
<dialog> <label>製品番号 <input type="text" readonly></label> <label>製品名 <input type="text" autofocus></label> </dialog>
autofocus
属性が無かった場合、
製品番号欄が[
ダイアログをフォーカスする手続きにより,フォーカスされる
]ことになろう。
それは,適理なふるまいであるが、
作者は,[
製品番号が読専な欄であり,利用者による入力を期待しないので、
フォーカス先として もっと関連する欄は,製品名欄であった
]ものと決定した。
なので、
作者は,既定を上書きするよう autofocus
を利用している。
If the autofocus attribute was not present, the Product Number field would have been focused by the dialog focusing steps. Although that is reasonable behavior, the author determined that the more relevant field to focus was the Product Name field, as the Product Number field is readonly and expects no user input. So, the author used autofocus to override the default.
作者が,既定では製品番号欄をフォーカスしたいと求める場合でも、
input
要素に autofocus
を利用して,
そのことを明示的に指定するのが最善になる。
そうすれば、
その意図は,そのコードの読者にとって明白になり、
未来において更新に直面したときにも,コードは堅牢であり続けることが確保される
(例えば、
別の開発者が,ノードツリー内で製品番号欄の前に “閉じる” ボタンを追加した場合でも)。
Even if the author wants to focus the Product Number field by default, they are best off explicitly specifying that by using autofocus on that input element. This makes the intent obvious to future readers of the code, and ensures the code stays robust in the face of future updates. (For example, if another developer added a close button, and positioned it in the node tree before the Product Number field).
利用者が直面するふるまいを成す別の重要な側面は、 ダイアログはスクロール可能になる(過フローする)か否かである。 一部の事例では, 過フローは避けれないが (例:利用者がテキストのズーム率を高く設定していたとき)、 一般には, 利用者はダイアログがスクロール可能になるとは期待しない。 ダイアログ要素に巨大なテキストノードを直に追加することは、 特に不良である — そうすると,ダイアログ要素自身を過フローさせる見込みが高まるので、 作者は,それを避けることが最善になる。 Another important aspect of user behavior is whether dialogs are scrollable or not. In some cases, overflow (and thus scrollability) cannot be avoided, e.g., when it is caused by the user's high text zoom settings. But in general, scrollable dialogs are not expected by users. Adding large text nodes directly to dialog elements is particularly bad as this is likely to cause the dialog element itself to overflow. Authors are best off avoiding them.
次のサービス約款ダイアログは、 上の示唆を尊重する: The following terms of service dialog respects the above suggestions.
<dialog style="height: 80vh;"> <div style="overflow: auto; height: 60vh;" autofocus> <p>西暦 2010年 4月 1日に このサイトを介して発注することにより、あなたは、今から未来永劫に、あなたの魂に対する譲渡不能な請求権を我々に是認することに同意したものとする。</p> <p>我々がこの請求権を行使したいと望んだ場合、あなたは、このサイトまたはその権限の委託先から書面による通知を受け取った時点から 5 営業日以内に、あなたの魂およびそれに対するいかなる請求権も明け渡すことに同意するものとする。</p> <!-- …等々,以下多数の <p> 要素を伴う… --> </div> <form method="dialog"> <button type="submit" value="agree">同意する</button> <button type="submit" value="disagree">同意しない</button> </form> </dialog>
既定では,[
ダイアログをフォーカスすることにより,
スクロール可能な div
要素が選ばれる
]ことになるが、
div
には
— 先の例と同様に,より明示的かつ未来の変更に対し堅牢になるよう —
autofocus
が付与されている。
Note how the dialog focusing steps would have picked the scrollable div element by default, but similarly to the previous example, we have placed autofocus on the div so as to be more explicit and robust against future changes.
対照的に、
サービス約款を表出している p
要素が,
そのような div
要素で包装されていなかった場合、
当の dialog
自身がスクロール可能になり,上の助言に違反する。
さらには,
autofocus
属性が どこにも無い場合、
そのようなマークアップパタンは,上の助言に違反する
— その結果、[
ダイアログをフォーカスする手続きにおける既定のふるまいにより,
フォーカスは “同意する” button
へ移る
]ことになり,利用者体験は不良になる。
In contrast, if the p elements expressing the terms of service did not have such a wrapper div element, then the dialog itself would become scrollable, violating the above advice. Furthermore, in the absence of any autofocus attribute, such a markup pattern would have violated the above advice and tripped up the dialog focusing steps's default behavior, and caused focus to jump to the Agree button, which is a bad user experience.
次のダイアログボックスには、
細則事項( small
)がある。
より重要な部分に利用者が注目するよう,
strong
要素が利用されている:
This dialog box has some small print. The strong element is used to draw the user's attention to the more important part.
<dialog> <h1>財布に追加する</h1> <p><strong><label for=amt>何枚のコインを追加しますか?</label></strong></p> <p><input id=amt name=amt type=number min=0 step=0.01 value=100></p> <p><small>コインの追加は、ご自身の責任で行なってください。</small></p> <p><label><input name=round type=checkbox>端数は丸める</label></p> <p><input type=button onclick="submit()" value="追加する"></p> </dialog>
dialog
要素の
open
属性は、
真偽属性である
— 指定された場合、[
当の要素は作動中であり、
利用者は,それとやりとりできる
]ことを指示する。
The open attribute is a boolean attribute. When specified, it indicates that the dialog element is active and that the user can interact with it.
closedby
内容属性は、
列挙属性であり,
次に挙げるキーワード, とり得る状態, それらの対応付けが定義される:
The closedby content attribute is an enumerated attribute with the following keywords and states:
キーワード | 状態 | 概略的な記述 |
---|---|---|
any
| 何でも | [ 閉じ要請/外側のクリック ]は、 当のダイアログを閉じる。 |
closerequest
| 閉じ要請 | 閉じ要請は、 当のダイアログを閉じる。 |
none
| なし | 当のダイアログを自動的に閉じるような利用者による動作は、 無い。 |
自動 |
[
当のダイアログが showModal() メソッドを利用して示された
]ときは 閉じ要請 として,
他の場合は なし としてふるまう。
|
closedby
属性の[
欠落している値用の既定の状態, 妥当でない値用の既定の状態
]は、
いずれも 自動 とする。
open
属性を有さない
dialog
要素は、
利用者に示されるべきでない。
この要件は、
スタイル層を通して間接的に実装されてもよい。
例えば,示唆される既定の具現化をサポートする UA は、
この要件を
§ 具現化に述べられる CSS 規則を利用して実装する。
A dialog element without an open attribute specified should not be shown to the user. This requirement may be implemented indirectly through the style layer. For example, user agents that support the suggested default rendering implement this requirement using the CSS rules described in the Rendering section.
注記:
ダイアログから open
属性を除去した場合,通例的にそれを隠すことになるが、
そうすると,いくつか奇異な結果も伴われる:
Removing the open attribute will usually hide the dialog. However, doing so has a number of strange additional consequences:
-
close
イベントは発火されない。 The close event will not be fired. -
[
close()
メソッド/閉じ要請 ]は,それ以降ダイアログを閉じれなくなる。 The close() method, and any close requests, will no longer be able to close the dialog. -
ダイアログが
showModal()
メソッドを利用して示されていた場合、 文書を阻んでいるモーダルダイアログになる。 If the dialog was shown using its showModal() method, the Document will still be blocked.
これらの理由から、
一般に, open
属性は 決して手動で除去しないほうが良い。
代わりに、
ダイアログを[[
requestClose()
/ close()
]メソッドを利用して閉じる
]か[
hidden
属性を利用して隠す
]こと。
For these reasons, it is generally better to never remove the open attribute manually. Instead, use the requestClose() or close() methods to close the dialog, or the hidden attribute to hide it.
dialog
要素には、
tabindex
属性を指定してはならない。
The tabindex attribute must not be specified on dialog elements.
- dialog.
show()
-
dialog
要素を表示する。 Displays the dialog element. - dialog.
showModal()
-
dialog
要素を表示して,それを最上層なモーダルダイアログにする。 Displays the dialog element and makes it the top-most modal dialog. -
このメソッドは、
autofocus
属性を尊守する。 This method honors the autofocus attribute. - dialog.
close([ result ])
-
dialog
要素を閉じる。 Closes the dialog element. -
引数は、
供されたならば,
dialog
の結果値を与える。 The argument, if provided, provides a return value. - dialog.
requestClose([ result ])
-
dialog をターゲットにする閉じ要請が送信されたかのように動作する
— まず
cancel
イベントを発火して、 それがpreventDefault()
で取り消されなかった場合には, dialog をclose()
メソッドと同じ仕方で閉じる (close
イベントを発火することも含む) よう続行することにより。 Acts as if a close request was sent targeting dialog, by first firing a cancel event, and if that event is not canceled with preventDefault(), proceeding to close the dialog in the same way as the close() method (including firing a close event). -
これは、[
閉じ要請でない閉じ用の affordance すべてが,このメソッドの call を経るようにする
]ことにより,[[
取り消し/閉じ
]用のロジックを[
cancel
/close
]イベントハンドラの中へ統合する ]ために利用できる便利用にある。 This is a helper utility that can be used to consolidate cancelation and closing logic into the cancel and close event handlers, by having all non-close request closing affordances call this method. -
このメソッドは、
closedby
属性を無視することに注意 — すなわち、 それがnone
に設定されていた場合でも, 同じふるまいが適用されることになる。 Note that this method ignores the closedby attribute: that is, even if closedby is set to "none", the same behavior will apply. - 引数は、 供されたならば, dialog の閉じ要請の返り値を供する。 The argument, if provided, provides a return value.
- dialog.
returnValue
[ = result ] -
dialog
の結果値を返す。 Returns the dialog's return value. - 設定して,結果値を更新できる。 Can be set, to update the return value.
show()
メソッド手続きは:
The show() method steps are:
-
IF[ これ°は
open
属性を有する ]:- IF[ これ°のモーダルか = false ] :RETURN
-
THROW
InvalidStateError
-
取り消されなかったか :← イベントを発火する( これ°,
beforetoggle
,ToggleEvent
) — 次のように初期化して :cancelable
属性 ← true,oldState
属性 ← "closed
",newState
属性 ← "open
" If the result of firing an event named beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", and the newState attribute initialized to "open" at this\ -
IF[ ∨↓ ]…
- 取り消されなかったか = false
-
これ°は
open
属性を有する
…ならば :RETURN
is false, then return.If this has an open attribute, then return. -
ダイアログ用のトグルイベントタスクをキューする( これ°, "
closed
", "open
" ) Queue a dialog toggle event task given this, "closed", and "open". -
これ°の属性値を設定する( "
open
", 空文字列 ) Add an open attribute to this, whose value is the empty string. - 文書 :← これ°のノード文書 ↓
- Assert: これ° ∉ 文書 の開いたダイアログリスト Assert: this's node document's open dialogs list does not contain this.
- 文書 の開いたダイアログリストにこれ°を付加する Add this to this's node document's open dialogs list.
- ダイアログ用の閉じ注視器を設定する( これ° ) Set the dialog close watcher with this.
- これ°の前回にフォーカスされた要素 ← フォーカスされている要素 Set this's previously focused element to the focused element.
-
« "
hint
", "auto
" » を成す 各( モード ) に対し:- popover リスト :← 文書が示している popover リストを取得する( 文書, モード )
- ある所 ← 最上層な popover 先祖を見出す( これ°, popover リスト, null , false )
- IF[ ある所 ≠ null ] :BREAK
- IF[ ある所 = null ] :ある所 ← 文書 If hideUntil is null, then set hideUntil to document.
- ある所までの popover をすべて隠す( ある所, false, true ) Run hide all popovers until given hideUntil, false, and true.
- ダイアログをフォーカスする( これ° ) Run the dialog focusing steps given this.
showModal()
メソッド手続きは
:モーダルダイアログを示す( これ° )
The showModal() method steps are to show a modal dialog given this.close(returnValue)
メソッド手続きは
:ダイアログを閉じる( これ°, returnValue )
The close(returnValue) method steps are:
• If returnValue is not given, then set it to null.
• Close the dialog this with returnValue.
requestClose(returnValue)
メソッド手続きは:
The requestClose(returnValue) method steps are:
-
IF[
これ°は
open
属性を有していない ] :RETURN If this does not have an open attribute, then return. - Assert: これ°の閉じ注視器 ≠ null Assert: this's close watcher is not null.
- これ°の閉じ要請メソッド用の閉じ注視器を可能化するか ← true Set dialog's enable close watcher for requestClose() to true.
- IF[ returnValue = ε ] :returnValue ← null If returnValue is not given, then set it to null.
- これ°の閉じ要請の返り値 ← returnValue Set this's request close return value to returnValue.
- 閉じ注視器に閉じるよう要請する( dialog の閉じ注視器, false ) Request to close dialog's close watcher with false.
- dialog の閉じ要請メソッド用の閉じ注視器を可能化するか ← false Set dialog's enable close watcher for requestClose() to false.
注記:
dialog
要素用の動詞には、[
示す( show ), 閉じる( close )
]が利用される
— より共通して反意語と考えられている[
示す( show ), 隠す( hide )
]や[
開く( open ), 閉じる( close )
]などの動詞ペアではなく。
このことは、
次に挙げる拘束に因る:
We use show/close as the verbs for dialog elements, as opposed to verb pairs that are more commonly thought of as antonyms such as show/hide or open/close, due to the following constraints:
-
ダイアログを[
隠すこと, 閉じること
]は異なる。
ダイアログを閉じることは、[
それに結果値を与える,
イベントを発火する,
他のダイアログ用にページを阻まなくする,
等々
]からなる。
一方で,ダイアログを隠すことは、
純粋に視覚的な特質についてであり,すでに[
hidden
属性で, あるいはopen
属性を除去することで ]行える何かである。 ( [open
属性を除去すること ]および[ その仕方でダイアログを隠すことは一般に欲されないこと ]についての上の注記も見よ。) Hiding a dialog is different from closing one. Closing a dialog gives it a return value, fires an event, unblocks the page for other dialogs, and so on. Whereas hiding a dialog is a purely visual property, and is something you can already do with the hidden attribute or by removing the open attribute. (See also the note above about removing the open attribute, and how hiding the dialog in that way is generally not desired.) -
ダイアログを[
示すこと, 開くこと
]は異なる。
ダイアログを開くことは、
ダイアログを[
作成すること, 示すこと
]からなる
(
window.open()
が新たな window を作成して, それを示すのと同様に)。 一方で, ダイアログを示すことは、 DOM 内にすでにあるdialog
要素をとって, 利用者から対話的かつ可視にする処理である。 Showing a dialog is different from opening one. Opening a dialog consists of creating and showing that dialog (similar to how window.open() both creates and shows a new window). Whereas showing the dialog is the process of taking a dialog element that is already in the DOM, and making it interactive and visible to the user. -
にもかかわらず,
dialog.open()
メソッドが在ったとすると、open
プロパティと競合することになる。 If we were to have a dialog.open() method despite the above, it would conflict with the dialog.open property.
さらには,[
dialog
要素の元の設計
]と同時代の[
他の多くの UI フレームワーク
]の調査から、
動詞ペア[
示す, 閉じる
]は,適理によくあることも明瞭になった。
Furthermore, a survey of many other UI frameworks contemporary to the original design of the dialog element made it clear that the show/close verb pair was reasonably common.
要約すると、[ ある種の動詞の含意, それらが技術文脈において どう利用されるか ]によっては, ペアにされた動作 — ダイアログを[ 示す, 閉じる ]など — は常に反意語として表出可能とは限らない。 In summary, it turns out that the implications of certain verbs, and how they are used in technology contexts, mean that paired actions such as showing and closing a dialog are not always expressible as antonyms.
returnValue
IDL 属性の:
The returnValue IDL attribute,\
- 取得子手続きは :RETURN これ°の結果値 on getting, must return the last value to which it was set.\
- 設定子手続きは :これ°の結果値 ← 所与の値 On setting, it must be set to the new value.\ ↓↓ When the element is created, it must be set to the empty string.
closedBy
IDL 属性の:
↓
-
取得子手続きは:
- 状態 :← ダイアログの closed-by 状態を算出する( これ° )
- Assert: 状態 ≠ 自動
-
RETURN
closedby
内容属性用のキーワードのうち 状態 に対応するもの
-
設定子手続きは
:これ°の属性値を設定する( "
closedby
", 所与の値 ) The closedBy setter steps are to set the closedby content attribute to the given value.
open
IDL 属性は、
open
内容属性を反映するものとする。
The open IDL attribute must reflect the open content attribute.
各文書は、
ダイアログ pointerdown ターゲット
を有する
— それは、[
null / HTMLDialogElement
]であり,初期時は null とする。
Each Document has a dialog pointerdown target, which is an HTML dialog element or null, initially null.
各 HTML 要素 要素 には、 前回にフォーカスされた要素 が結び付けられる。 それは、[ null / 要素 ]であり,初期時は null とする — これは: Each HTML element has a previously focused element which is null or an element, and it is initially null.\
-
要素 に対し[
showModal()
/show()
]が call されたときには、 その手続きの中でダイアログをフォーカスする前に, 現在フォーカスされている要素に設定される。 When showModal() and show() are called, this element is set to the currently focused element before running the dialog focusing steps.\ -
要素 が
popover
属性を有する場合、 popover を示す間に現在フォーカスされている要素に設定される。 Elements with the popover attribute set this element to the currently focused element during the show popover algorithm.
各 dialog
要素には、
次に挙げるものが結び付けられる:
↓
-
結果値 :文字列 — 初期時は空文字列とする。
【 これは、 この訳にて導入した用語。 原文では、 (マークアップなしに) “return value” と記されていて, (アルゴリズムの) “返り値” と紛らわしいので。 それに伴い,初期値の要件も
returnValue
IDL 属性の記述から ここに移動している。 】 - トグルタスク追跡子 : null /あるトグルタスク追跡子 — 初期時は null とする。 Each dialog element has a dialog toggle task tracker, which is a toggle task tracker or null, initially null.
- 閉じ注視器 : null /ある閉じ注視器 — 初期時は null とする。 Each dialog element has a close watcher, which is a close watcher or null, initially null.
- 閉じ要請の返り値 :【 null /】 文字列 — 初期時は null とする。 Each dialog element has a request close return value, which is a string, initially null.
- 閉じ要請メソッド用の閉じ注視器を可能化するか :真偽値 — 初期時は false とする。 Each dialog element has an enable close watcher for requestClose() boolean, initially false.
- モーダルか :真偽値 — 初期時は false とする。 Each dialog element has an is modal boolean, initially false.
dialog
要素用の HTML 要素除去時の手続きは、
所与の
( 除去されるノード, 旧親 )
に対し:
The dialog HTML element removing steps, given removedNode and oldParent, are:
-
IF[ 除去されるノード の閉じ注視器 ≠ null ]: If removedNode's close watcher is not null, then:
- 閉じ注視器を破壊する( 除去されるノード の閉じ注視器 ) Destroy removedNode's close watcher.
- 除去されるノード の閉じ注視器 ← null Set removedNode's close watcher to null.
- IF[ 除去されるノード ∈ 除去されるノード のノード文書の上端層 ] :上端層から要素を即時に除去する( 除去されるノード ) If removedNode's node document's top layer contains removedNode, then remove an element from the top layer immediately given removedNode.
- 除去されるノード のモーダルか ← false Set is modal of removedNode to false.
- 除去されるノード のノード文書の開いたダイアログリストから 除去されるノード を除去する Remove removedNode from removedNode's node document's open dialogs list.
モーダルダイアログを示す
アルゴリズムは、
所与の
( dialog
要素 dialog )
に対し:
To show a modal dialog given a dialog element subject:
-
IF[
dialog は
open
属性を有する ]∧[ dialog のモーダルか = true ] :RETURN If subject has an open attribute and is modal of subject is true, then return. -
IF[ ∨↓ ]…
…ならば :THROW
If subject has an open attribute, then throw an "InvalidStateError" DOMException.If subject's node document is not fully active, then throw an "InvalidStateError" DOMException.If subject is not connected, then throw an "InvalidStateError" DOMException.If subject is in the popover showing state, then throw an "InvalidStateError" DOMException.InvalidStateError
-
取り消されなかったか :← イベントを発火する( dialog,
beforetoggle
,ToggleEvent
) — 次のように初期化して :cancelable
属性 ← true,oldState
属性 ← "closed
",newState
属性 ← "open
" If the result of firing an event named beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", and the newState attribute initialized to "open" at subject\ -
IF[ ∨↓ ]…
- 取り消されなかったか = false
-
dialog は
open
属性を有する - dialog は接続されていない
- dialog の popover 可視性状態 = 示している
…ならば :RETURN
is false, then return.If subject has an open attribute, then return.If subject is not connected, then return.If subject is in the popover showing state, then return. -
ダイアログ用のトグルイベントタスクをキューする( dialog, "
closed
", "open
" ) Queue a dialog toggle event task given subject, "closed", and "open". -
dialog の属性値を設定する( "
open
", 空文字列 ) Add an open attribute to subject, whose value is the empty string. - dialog のモーダルか ← true Set is modal of subject to true.
- 文書 :← dialog のノード文書 ↓
- Assert: dialog ∉ 文書 の開いたダイアログリスト Assert: subject's node document's open dialogs list does not contain subject.
- 文書 の開いたダイアログリストに dialog を付加する Add subject to subject's node document's open dialogs list.
-
dialog を 文書 を阻んでいるモーダルダイアログにする Let subject's node document be blocked by the modal dialog subject.
注記: これは、 文書 が指名する被フォーカス区画を不活にする (現在の被フォーカス区画が dialog の shadow も含めた子孫でない限り)。 そのような事例では、 文書 が指名する被フォーカス区画は, すぐに表示域に設定し直されることになる — が、 数段先にて,フォーカス先として もっと良い候補を見出そうと試みることになる。 This will cause the focused area of the document to become inert (unless that currently focused area is a shadow-including descendant of subject). In such cases, the focused area of the document will soon be reset to the viewport. In a couple steps we will attempt to find a better candidate to focus.
- IF[ dialog ∉ 文書 の上端層 ] :上端層に要素を追加する( dialog ) If subject's node document's top layer does not already contain subject, then add an element to the top layer given subject.
- ダイアログ用の閉じ注視器を設定する( dialog ) Set the dialog close watcher with subject.
- dialog の前回にフォーカスされた要素 ← フォーカスされている要素 Set subject's previously focused element to the focused element.
-
« "
hint
", "auto
" » を成す 各( モード ) に対し:- popover リスト :← 文書が示している popover リストを取得する( 文書, モード )
- ある所 ← 最上層な popover 先祖を見出す( dialog, popover リスト, null , false )
- IF[ ある所 ≠ null ] :BREAK
- IF[ ある所 = null ] :ある所 ← 文書 If hideUntil is null, then set hideUntil to document.
- ある所までの popover をすべて隠す( ある所, false, true ) Run hide all popovers until given hideUntil, false, and true.
- ダイアログをフォーカスする( dialog ) Run the dialog focusing steps given subject.
ダイアログ用の閉じ注視器を設定する
アルゴリズムは、
所与の
( dialog
要素 dialog )
に対し:
To set the dialog close watcher, given a dialog element dialog:
-
dialog の閉じ注視器 ← 閉じ注視器を確立する( dialog に関連する大域オブジェクト ) — 次も与える下で: Set dialog's close watcher to the result of establishing a close watcher given dialog's relevant global object, with:
-
取り消し動作 は、
所与の
( 閉じを防止し得るか )
に対し
:イベントを発火する( dialog,
cancel
) — 次のように初期化して :cancelable
属性 ← 閉じを防止し得るか cancelAction given canPreventClose being to return the result of firing an event named cancel at dialog, with the cancelable attribute initialized to canPreventClose. - 閉じ動作 は :ダイアログを閉じる( dialog, dialog の閉じ要請の返り値 ) closeAction being to close the dialog given dialog and dialog's request close return value.
- 可能化状態を取得する は :RETURN IS[ dialog の閉じ要請メソッド用の閉じ注視器を可能化するか = true ]∨[ ダイアログの closed-by 状態を算出する( dialog ) ≠ なし ] getEnabledState being to return true if dialog's enable close watcher for requestClose() is true or dialog's computed closed-by state is not None; otherwise false.
-
取り消し動作 は、
所与の
( 閉じを防止し得るか )
に対し
:イベントを発火する( dialog,
dialog
要素用の
呼び出し元コマンドは妥当か?手続き
は、
所与の
( command
属性 コマンド )
に対し
:RETURN IS[
コマンド の状態 ∈ { 閉じる, モーダルを示す }
]
The is valid invoker command steps for dialog elements, given a command attribute command, are:
• If command is in the Close state or in the Show Modal state, then return true.
• Return false.
dialog
要素用の呼び出し元コマンド手続きは、
所与の
( 要素 dialog, 要素 呼び出し元, command
属性 コマンド )
に対し:
The invoker command steps for dialog elements, given an element element, an element invoker, and a command attribute command, are:
- IF[ dialog の popover 可視性状態 = 示している ] :RETURN If element is in the popover showing state, then return.
-
IF[
コマンド の状態 = 閉じる
]∧[
dialog は
open
属性を有する ] :ダイアログを閉じる( dialog, 呼び出し元 の値 ) If command is in the Close state and element has an open attribute: • Let value be invoker's value. • Close the dialog element with value. -
IF[
コマンド の状態 = モーダルを示す
]∧[
dialog は
open
属性を有さない ] :モーダルダイアログを示す( dialog ) If command is the Show Modal state and element does not have an open attribute, then show a modal dialog given element.
次のボタンは、
commandfor
属性を利用して,
“確認用の” dialog
が作動化されたときモーダルとして開く(閉じる)ようにする:
The following buttons use commandfor to open and close a "confirm" dialog as modal when activated:
<button type=button commandfor="the-dialog" command="show-modal"> 削除する </button> <dialog id="the-dialog"> <form action="/delete" method="POST"> <button type="submit"> 削除する </button> <button commandfor="the-dialog" command="close"> 取り消す </button> </form> </dialog>
ダイアログを閉じる
アルゴリズムは、
所与の
( dialog
要素 dialog, [
null /文字列
] 結果 )
に対し:
When a dialog element subject is to be closed, with null or a string result, run these steps:
-
IF[
dialog は
open
属性を有さない ] :RETURN If subject does not have an open attribute, then return. -
イベントを発火する( dialog,
beforetoggle
,ToggleEvent
) — 次のように初期化して :oldState
属性 ← "open
",newState
属性 ← "closed
" Fire an event named beforetoggle, using ToggleEvent, with the oldState attribute initialized to "open" and the newState attribute initialized to "closed" at subject. -
IF[
dialog は
open
属性を有さない ] :RETURN If subject does not have an open attribute, then return. -
ダイアログ用のトグルイベントタスクをキューする( これ°, "
open
", "closed
" ) Queue a dialog toggle event task given subject, "open", and "closed". -
dialog から
open
属性を除去する Remove subject's open attribute. - IF[ dialog のモーダルか = true ] :上端層から要素を除去するよう要請する( dialog ) If is modal of subject is true, then request an element to be removed from the top layer given subject.
- モーダルであったか :← dialog のモーダルか Let wasModal be the value of subject's is modal flag.
- dialog のモーダルか ← false Set is modal of subject to false.
- dialog のノード文書 の開いたダイアログリストから dialog を除去する Remove subject from subject's node document's open dialogs list.
- IF[ 結果 ≠ null ] :dialog の 結果値 ← 結果 If result is not null, then set the returnValue attribute to result.
- 【 dialog の】閉じ要請の返り値 ← null Set the request close return value to null.
-
IF[ dialog の前回にフォーカスされた要素 ≠ null ]: If subject's previously focused element is not null, then:
- 要素 :← dialog の前回にフォーカスされた要素 Let element be subject's previously focused element.
- dialog の前回にフォーカスされた要素 ← null Set subject's previously focused element to null.
-
IF[ dialog のノード文書が指名する被フォーカス区画の DOM アンカーは, dialog の shadow も含めた広義子孫である ]∨[ モーダルであったか = true ] :オブジェクトをフォーカスする( 要素 ) If subject's node document's focused area of the document's DOM anchor is a shadow-including inclusive descendant of subject, or wasModal is true, then run the focusing steps for element;\
この段を行うときは、 表示域はスクロールされるべきでない。 the viewport should not be scrolled by doing this step.
-
要素タスクをキューする( 利用者対話タスクソース, dialog, 次の手続き )
Queue an element task on the user interaction task source given the subject element to fire an event named close at subject. -
IF[ dialog の閉じ注視器 ≠ null ]: If subject's close watcher is not null, then:
- 閉じ注視器を破壊する( dialog の閉じ注視器 ) Destroy subject's close watcher.
- dialog の閉じ注視器 ← null Set subject's close watcher to null.
ダイアログ用のトグルイベントタスクをキューする
アルゴリズムは、
所与の
( dialog
要素 dialog, 文字列 旧状態, 文字列 新状態 )
に対し:
To queue a dialog toggle event task given a dialog element element, a string oldState, and a string newState:
-
IF[ dialog のトグルタスク追跡子 ≠ null ]: If element's dialog toggle task tracker is not null, then:
-
タスク :← 要素タスクをキューする( DOM 操作タスクソース, dialog, 次の手続き ) Queue an element task given the DOM manipulation task source and element to\
手続きは: run the following steps:
-
イベントを発火する( dialog,
toggle
,ToggleEvent
) — 次のように初期化して :oldState
属性 ← 旧状態,newState
属性 ← 新状態 Fire an event named toggle at element, using ToggleEvent, with the oldState attribute initialized to oldState and the newState attribute initialized to newState. - dialog のトグルタスク追跡子 ← null Set element's dialog toggle task tracker to null.
-
イベントを発火する( dialog,
- dialog のトグルタスク追跡子 ← 次を伴う構造体 :タスク ← タスク, 旧状態 ← 旧状態 Set element's dialog toggle task tracker to a struct with task set to the just-queued task and old state set to oldState.
ダイアログの closed-by 状態を算出する
アルゴリズムは、
所与の
( dialog
dialog )
に対し:
To retrieve a dialog's computed closed-by state, given a dialog dialog:
ダイアログをフォーカスする
アルゴリズムは、
所与の
( dialog
要素 dialog )
に対し:
The dialog focusing steps, given a dialog element subject, are as follows:
- IF[ フォーカスを許容する手続き( dialog のノード文書 ) = false ] :RETURN false If the allow focus steps given subject's node document return false, then return.
- コントロール :← null Let control be null.
-
IF[
dialog は
autofocus
属性を有さない ] :コントロール ← フォーカス委任先( dialog ) If subject has the autofocus attribute, then set control to subject.If control is null, then set control to the focus delegate of subject. - IF[ コントロール = null ] :コントロール ← dialog If control is null, then set control to subject.
-
オブジェクトをフォーカスする( コントロール ) Run the focusing steps for control.
注記: コントロール はフォーカス可能でない場合、 これは何もしない。 そうなるのは、[ dialog にフォーカス委任先は無かった ]かつ[ UA は[
dialog
要素は、 一般に,フォーカス可能でない ]ものと裁定していた ]ときに限られる。 その事例では、 当の文書が指名する被フォーカス区画に先の改変を適用することになる。 If control is not focusable, this will do nothing. This would only happen if subject had no focus delegate, and the user agent decided that dialog elements were not generally focusable. In that case, any earlier modifications to the focused area of the document will apply. - トップ文書 :← コントロール のノードナビ可能のトップレベル辿り可能にて作動中な文書 Let topDocument be control's node navigable's top-level traversable's active document.
- IF[ ( コントロール のノード文書の生成元, トップ文書 の生成元 ) は同一生成元でない ] :RETURN If control's node document's origin is not the same as the origin of topDocument, then return.
- トップ文書 の自動フォーカス候補群を空にする Empty topDocument's autofocus candidates.
- トップ文書 の自動フォーカスは処理済みか ← true Set topDocument's autofocus processed flag to true.
4.11.5. ダイアログを軽く退ける
注記:
“軽く退ける( light dismiss )” とは、
次を意味する
:dialog
要素のうち[
その closedby
属性の状態 = 何でも
]を満たすものに対し,当の要素の外側をクリックすると、
当の要素を閉じることになる。
このふるまいは、[
そのような dialog
が閉じ要請に対しどう応答するか
]に対する追加である。
"Light dismiss" means that clicking outside of a dialog element whose closedby attribute is in the Any state will close the dialog element. This is in addition to how such dialogs respond to close requests.
開いたダイアログたちを軽く退ける
アルゴリズムは、
所与の
( PointerEvent
イベント )
に対し:
To light dismiss open dialogs, given a PointerEvent event:
-
Assert:
イベント の
isTrusted
属性 = true Assert: event's isTrusted attribute is true. - Assert: イベント のターゲット ≠ null 【この段は、この訳による補完。】
- 文書 :← イベント のターゲットのノード文書 Let document be event's target's node document.
- IF[ 文書 の開いたダイアログリストは空である ] :RETURN If document's open dialogs list is empty, then return.
- 先祖 :← 最も近いクリックされたダイアログを見出す( イベント ) Let ancestor be the result of running nearest clicked dialog given event.
-
IF[
イベント の
type
= "pointerdown
" ] :文書 のダイアログ pointerdown ターゲット ← 先祖 If event's type is "pointerdown", then set document's dialog pointerdown target to ancestor. -
ELSE IF[ イベント の
type
= "pointerup
" ]: If event's type is "pointerup", then:- 同じターゲットか :← IS[ 先祖 = 文書 のダイアログ pointerdown ターゲット ] Let sameTarget be true if ancestor is document's dialog pointerdown target.
- 文書 のダイアログ pointerdown ターゲット ← null Set document's dialog pointerdown target to null.
- IF[ 同じターゲットか = false ] :RETURN If sameTarget is false, then return.
- 最上層なダイアログ :← 文書 の開いたダイアログリストを成す最後の要素 Let topmostDialog be the last element of document's open dialogs list.
- IF[ 先祖 = 最上層なダイアログ ] :RETURN If ancestor is topmostDialog, then return.
- IF[ ダイアログの closed-by 状態を算出する( 最上層なダイアログ ) ≠ 何でも ] :RETURN If topmostDialog's computed closed-by state is not Any, then return.
- Assert: 最上層なダイアログ の閉じ注視器 ≠ null Assert: topmostDialog's close watcher is not null.
- 閉じ注視器に閉じるよう要請する( 最上層なダイアログ の閉じ注視器, false ) Request to close topmostDialog's close watcher with false.
軽く退けるふるまいを走らす
アルゴリズムは、
所与の
( PointerEvent
イベント )
に対し:
To run light dismiss activities, given a PointerEvent event:
- 開いた popover たちを軽く退ける( イベント ) Run light dismiss open popovers with event.
- 開いたダイアログたちを軽く退ける( イベント ) Run light dismiss open dialogs with event.
軽く退けるふるまいを走らすは、 利用者がページ上のどこでも[ クリックした/タッチした ]ときに, [POINTEREVENTS] 仕様により call されることになる。 Run light dismiss activities will be called by the Pointer Events spec when the user clicks or touches anywhere on the page.
最も近いクリックされたダイアログを見出す
アルゴリズムは、
所与の
( PointerEvent
イベント )
に対し:
To find the nearest clicked dialog, given a PointerEvent event:
- ターゲット :← イベント のターゲット Let target be event's target.
-
IF[ ∧↓ ]…
-
ターゲット は
dialog
要素である -
ターゲット は
open
属性を有している - ターゲット のモーダルか = true
-
イベント の (
clientX
,clientY
) は、 ターゲット の限界域の外側にある注記: この条件は、[ イベント が当のダイアログの
::backdrop
疑似要素で生じたものである場合 ]でも[ ターゲット は当のdialog
要素になる ]ことから必要になる。
…ならば :RETURN null
If target is a dialog element, target has an open attribute, target's is modal is true, and event's clientX and clientY are outside the bounds of target, then return null.The check for clientX and clientY is because a pointer event that hits the ::backdrop pseudo element of a dialog will result in event having a target of the dialog element itself. -
ターゲット は
- 現在のノード :← ターゲット Let currentNode be target.
-
WHILE[ 現在のノード ≠ null ]: While currentNode is not null:
- RETURN null Return null.