4.10.18. 各種~form~controlに共通な属性
4.10.18.2. 要素~方向性の提出-法: `dirname^a 属性
~form~control要素の
`dirname@a
属性は、
要素の`方向性$の提出を可能化し,`~form提出$の際に この値を包含させる名前を与える。
この属性には、
空~文字列を指定してはナラナイ。
◎
The dirname attribute on a form control element enables the submission of the directionality of the element, and gives the name of the control that contains this value during form submission. If such an attribute is specified, its value must not be the empty string.
~text~controlと提出-~buttonを包含する~formの例:
◎
In this example, a form contains a text control and a submission button:
`directionality-1^xCode
利用者がこの~formを提出したとき、
~UAは,順に[
"comment", "comment.dir", "mode"
]と称される 3 個の欄を含める。
利用者が "Hello" と手入力していたなら、
その提出~本体は,次の様になるであろう:
◎
When the user submits the form, the user agent includes three fields, one called "comment", one called "comment.dir", and one called "mode"; so if the user types "Hello", the submission body might be something like:
comment=Hello&comment.dir=ltr&mode=add
利用者が手動で書字~方向を右横書きに切り替えて,
"مرحبا"
と手入力していたなら、
その提出~本体は,次の様になるであろう:
◎
If the user manually switches to a right-to-left writing direction and enters "مرحبا", the submission body might be something like:
comment=~rtlWord1&comment.dir=rtl&mode=add
4.10.18.6. ~form提出用の属性
`~form提出用の属性@
は、
`form$e 要素にも,`提出-~button$†にも指定できる。
(† ~formを提出する~buttonを表現する要素
— 例えば `input$e 要素のうち `type$a 属性が `Submit$st 状態にあるもの。)
◎
Attributes for form submission can be specified both on form elements and on submit buttons (elements that represent buttons that submit forms, e.g. an input element whose type attribute is in the Submit Button state).
`form$e 要素には、
次に挙げる`~form提出用の属性$が指定されてもヨイ
⇒
`action$a, `enctype$a, `method$a, `novalidate$a, `target$a
◎
The attributes for form submission that may be specified on form elements are action, enctype, method, novalidate, and target.
`提出-~button$には、
次に挙げる,対応する`~form提出用の属性$が指定されてもヨイ
⇒
`formaction$a, `formenctype$a, `formmethod$a, `formnovalidate$a, `formtarget$a
— これらの属性の省略-時の既定は、
`form$e 要素に与えられた対応する属性の値になる。
◎
The corresponding attributes for form submission that may be specified on submit buttons are formaction, formenctype, formmethod, formnovalidate, and formtarget. When omitted, they default to the values given on the corresponding attributes on the form element.
[
`action@a
/
`formaction@a
]内容~属性に指定する値は、
`前後~空白~可の妥当かつ空でない~URL$でなければナラナイ。
◎
The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.
%要素 の
`動作@
は、
次に従って決定される:
-
~IF[
%要素 は`提出-~button$である
]~AND[
%要素 は `formaction$a 属性を有する
]
⇒
~RET その属性の値
-
%要素 ~SET %要素 の`~form所有者$
-
~IF[
%要素 ~NEQ ~NULL
]~AND[
%要素 は `action$a 属性を有する
]
⇒
~RET その属性の値
-
~RET 空~文字列
◎
The action of an element is the value of the element's formaction attribute, if the element is a submit button and has such an attribute, or the value of its form owner's action attribute, if it has one, or else the empty string.
[
`method@a
/
`formmethod@a
]内容~属性は,`列挙d属性$であり、
次に挙げる~keyword, とり得る状態, それらの対応付けが定義される:
◎
The method and formmethod content attributes are enumerated attributes with the following keywords and states:
~keyword
| 状態
| 概略的な記述
|
`get@v
| `GET@st
|
次を指示する
⇒
当の~formは、
~HTTP `GET$M ~methodを利用することになる。
|
`post@v
| `POST@st
|
次を指示する
⇒
当の~formは、
~HTTP `POST$M ~methodを利用することになる。
|
`dialog@v
| `dialog@st
|
次を指示する
⇒
当の~formは、
それが見出される `dialog$e ~boxが[
在るならば それを閉じる/
無いならば 提出しない
]ことが意図される。
|
◎
Keyword|State|Brief description
get|GET|Indicates the form will use the HTTP GET method.
post|POST|Indicates the form will use the HTTP POST method.
dialog|Dialog|Indicates the form is intended to close the dialog box in which the form finds itself, if any, and otherwise not submit.
`method$a 属性の[
`欠落~値~用の既定の状態$/`妥当でない値~用の既定の状態$
]は、
`GET$st とする。
◎
The method attribute's missing value default and invalid value default are both the GET state.
`formmethod$a 属性の[
`欠落~値~用の既定の状態$は ε /
`妥当でない値~用の既定の状態$は `GET$st
]とする。
【前者の状態は、利用されない(次の段落)。】
◎
The formmethod attribute has no missing value default, and its invalid value default is the GET state.
要素の
`~method@
は、
上に挙げた いずれかの状態をとる
— それは、[[
要素は`提出-~button$である
]~AND[
要素は `formmethod$a 属性を有する
]ならば その属性の状態 /
~ELSE_ 要素の`~form所有者$の `method$a 属性の状態
]とする。
◎
The method of an element is one of those states. If the element is a submit button and has a formmethod attribute, then the element's method is that attribute's state; otherwise, it is the form owner's method attribute's state.
`method$a 属性を利用して 既定の値 `get$v を明示的に指定する例
— 探索~queryは、
~URL内に提出されるようになる:
◎
Here the method attribute is used to explicitly specify the default value, "get", so that the search query is submitted in the URL:
`method-get-1^xCode
他方, `method$a 属性に値 `post$v に指定した場合、
利用者の~messageは,~HTTP要請の本体~内に提出される:
◎
On the other hand, here the method attribute is used to specify the value "post", so that the user's message is submitted in the HTTP request's body:
`method-post-1^xCode
次の例では、
`form$e は `dialog$e に利用される。
~formが提出されたとき~dialogを自動的に閉じるため、
`method$a 属性には `dialog$v ~keywordが利用されている。
◎
In this example, a form is used with a dialog. The method attribute's "dialog" keyword is used to have the dialog automatically close when the form is submitted.
`method-dialog-1^xCode
[
`enctype@a
/
`formenctype@a
]内容~属性は,`列挙d属性$であり、
次に挙げる~keywordが定義される
— それぞれ、
同じ名前の状態に対応付けられる:
◎
The enctype and formenctype content attributes are enumerated attributes with the following keywords and states:
-
`application/x-www-form-urlencoded@v
◎
The "application/x-www-form-urlencoded" keyword and corresponding state.
-
`multipart/form-data@v
◎
The "multipart/form-data" keyword and corresponding state.
-
`text/plain@v
◎
The "text/plain" keyword and corresponding state.
`enctype$a 属性の[
`欠落~値~用の既定の状態$/`妥当でない値~用の既定の状態$
]は、
`application/x-www-form-urlencoded$v とする。
◎
The attribute's missing value default and invalid value default are both the application/x-www-form-urlencoded state.
`formenctype$a 属性の[
`欠落~値~用の既定の状態$は ε/
`妥当でない値~用の既定の状態$は `application/x-www-form-urlencoded$v
]とする。
【前者の状態は、利用されない(次の段落)。】
◎
The formenctype attribute has no missing value default, and its invalid value default is the application/x-www-form-urlencoded state.
要素の
`~enctype@
は、
上に挙げた 3 種の状態いずれかをとり,[
要素は[
`提出-~button$である
]~AND[
`formenctype$a 属性を有する
]ならばその属性の状態 /
~ELSE_ 要素の`~form所有者$の `enctype$a 属性の状態
]になるとする。
◎
The enctype of an element is one of those three states. If the element is a submit button and has a formenctype attribute, then the element's enctype is that attribute's state; otherwise, it is the form owner's enctype attribute's state.
[
`target@a
/
`formtarget@a
]内容~属性に指定する値は、
`妥当な~navigable~target名または~keyword$でなければナラナイ。
◎
The target and formtarget content attributes, if specified, must have values that are valid navigable target names or keywords.
[
`novalidate@a
/
`formnovalidate@a
]内容~属性は`真偽-属性$である。
在る場合、[
~form/要素
]は,提出の間に検証されないことを指示する。
◎
The novalidate and formnovalidate content attributes are boolean attributes. If present, they indicate that the form is not to be validated during submission.
要素の
`検証なし状態@
は、
~IS ~OR↓ になるとする:
-
[
要素は`提出-~button$である
]~AND[
要素は `formnovalidate$a 属性を有する
]
-
要素の`~form所有者$は[
~NULL でない, かつ `novalidate$a 属性を有する
]
◎
The no-validate state of an element is true if the element is a submit button and the element's formnovalidate attribute is present, or if the element's form owner's novalidate attribute is present, and false otherwise.
この属性は、
検証~拘束を備える~formに “保存-” ~buttonを含ませて,[
利用者が,~form内の~dataを全部的に手入力していない場合でも、
それらの進捗を保存できる
]ようにするときに有用になる。
次の単純な~form例には、
2 個の必須の欄に加えて, 3 個の~button
— ~form提出-用の~button(両~欄とも埋めることが要求される),
保存-用の~button(利用者が後で戻って来て埋められるようにする),
~formを まるごと取消す~button —
がある:
◎
This attribute is useful to include "save" buttons on forms that have validation constraints, to allow users to save their progress even though they haven't fully entered the data in the form. The following example shows a simple form that has two required fields. There are three buttons: one to submit the form, which requires both fields to be filled in; one to save the form so that the user can come back and fill it in later; and one to cancel the form altogether.
`method-post-2^xCode
`action@m
~IDL属性は、
`action$a 内容~属性を`反映する$モノトスル。
ただし,取得子は、
コレが次を満たさないならば,コレの`~node文書$の`~URL$docを返すモノトスル
⇒
`action$a 内容~属性を有していて,その値 ~NEQ 空~文字列
◎
The action IDL attribute must reflect the content attribute of the same name, except that on getting, when the content attribute is missing or its value is the empty string, the element's node document's URL must be returned instead.\
`target@m
~IDL属性は、
`target$a 内容~属性を`反映する$モノトスル。
◎
The target IDL attribute must reflect the content attribute of the same name.\
`method@m
~IDL属性は、
`既知な値のみに制限され$る下で,
`method$a 内容~属性を`反映する$モノトスル。
[
`enctype@m,
`encoding@m
]両~IDL属性とも、
`既知な値のみに制限され$る下で,
`enctype$a 内容~属性を`反映する$モノトスル。
◎
The method and enctype IDL attributes must reflect the respective content attributes of the same name, limited to only known values.\
◎
The encoding IDL attribute must reflect the enctype content attribute, limited to only known values.\
`noValidate@m
~IDL属性は、
`novalidate$a 内容~属性を`反映する$モノトスル。
◎
The noValidate IDL attribute must reflect the novalidate content attribute.\
`formAction@m
~IDL属性は、
`formaction$a 内容~属性を`反映する$モノトスル。
ただし,取得子は、
コレが次を満たさないならば,コレの`~node文書$の`~URL$docを返すモノトスル
⇒
`formaction$a 内容~属性を有していて,その値 ~NEQ 空~文字列
◎
The formAction IDL attribute must reflect the formaction content attribute, except that on getting, when the content attribute is missing or its value is the empty string, the element's node document's URL must be returned instead.\
`formEnctype@m
~IDL属性は、
`既知な値のみに制限され$る下で,
`formenctype$a 内容~属性を`反映する$モノトスル。
◎
The formEnctype IDL attribute must reflect the formenctype content attribute, limited to only known values.\
`formMethod@m
~IDL属性は、
`既知な値のみに制限され$る下で,
`formmethod$a 内容~属性を`反映する$モノトスル。
◎
The formMethod IDL attribute must reflect the formmethod content attribute, limited to only known values.\
`formNoValidate@m
~IDL属性は、
`formnovalidate$a 内容~属性を`反映する$モノトスル。
◎
The formNoValidate IDL attribute must reflect the formnovalidate content attribute.\
`formTarget@m
~IDL属性は、
`formtarget$a 内容~属性を`反映する$モノトスル。
◎
The formTarget IDL attribute must reflect the formtarget content attribute.
4.10.18.7. ~autofill
【
この節の内容は、
`別~page@~HTMLautofill#autofill$にて。
】
4.10.19. ~text~control選択~用の~API
[
`input$e / `textarea$e
]要素は、
それらの選択を取扱うためとして,いくつかの~memberを定義している。
それらは、
ここに定義される~algoを共有する。
◎
The input and textarea elements define several attributes and methods for handling their selection. Their shared algorithms are defined here.
この節における
`~offset@
とは、
~text内の,論理-順序による[
始端/終端/隣接する ある 2 個の`符号単位$の狭間
]を指す,負でない整数であり、
`~offset$ 0 は~textの始端を指すとする(したがって,`~offset$[
~textの`長さ$
]は終端を指すことになる)。
【
この`~offset$の定義は、
簡潔に記すために,この訳に導入している
(原文の “`offset^en” は、
文字列~内の “`符号単位$の~offset” を表していて,記述がまわりくどいので)。
】
- %element.`select()$m
-
~text~control内のすべてを選択する。
◎
Selects everything in the text control.
- %element.`selectionStart$m [ = %value ]
-
選択の始端を指す`~offset$を返す。
◎
Returns the offset to the start of the selection.
-
設定して,選択の始端を変更できる。
◎
Can be set, to change the start of the selection.
- %element.`selectionEnd$m [ = %value ]
-
選択の終端を指す`~offset$を返す。
◎
Returns the offset to the end of the selection.
-
設定して,選択の終端を変更できる。
◎
Can be set, to change the end of the selection.
- %element.`selectionDirection$m [ = %value ]
-
現在の`選択~方向$を返す。
◎
Returns the current direction of the selection.
-
設定して,現在の`選択~方向$を変更できる。
◎
Can be set, to change the direction of the selection.
-
アリな値は[
`forward^l, `backward^l, `none^l
]のいずれかである。
◎
The possible values are "forward", "backward", and "none".
- %element.`setSelectionRange(start, end [, direction])$m
-
選択の[
始端, 終端, 方向
]を[
%start, %end, %direction
]に変更する。
%direction が省略された場合、
方向は~platformの既定のそれ( `forward^l または `none^l )に再設定される。
◎
Changes the selection to cover the given substring in the given direction. If the direction is omitted, it will be reset to be the platform default (none or forward).
- %element.`setRangeText(replacement [, start, end [, selectionMode ] ])$m
-
~textのある範囲を,新たな~textに置換する。
%start, %end 引数が供されない場合の範囲は、
選択~全体と見做される。
◎
Replaces a range of text with the new text. If the start and end arguments are not provided, the range is assumed to be the selection.
-
~~最後の引数は、
~textが置換された後に,選択が どう設定されることになるかを決定する。
アリな値は:
◎
The final argument determines how the selection will be set after the text has been replaced. The possible values are:
- `select$l
-
新たに挿入された~textを選択する。
◎
Selects the newly inserted text.
- `start$l
-
選択の始端, 終端ともに 挿入された~textの直前に移動する。
◎
Moves the selection to just before the inserted text.
- `end$l
-
選択の始端, 終端ともに 挿入された~textの直後に移動する。
◎
Moves the selection to just after the selected text.
- `preserve$l
-
選択をなるべく保全しようと試みる。
これが既定。
◎
Attempts to preserve the selection. This is the default.
[
これらの~APIが`適用される$すべての `input$e 要素, および `textarea$e 要素
]は、
どの時点でも(要素が`具現化されて$いなくとも),[
`選択@,
`~text手入力~cursor位置@
]のどちらかは有するとする
— これらは、
~controlに`関連な値$における`~offset$で測定される。
初期~状態では、
~controlの始端を指す~text手入力~cursor位置を有するモノトスル。
◎
All input elements to which these APIs apply, and all textarea elements, have either a selection or a text entry cursor position at all times (even for elements that are not being rendered), measured in offsets into the code units of the control's relevant value. The initial state must consist of a text entry cursor at the beginning of the control.
【
~text手入力~cursor位置は,実質的には “始端と終端が一致する空な選択” と同じに見受けられる( “空な選択” と “選択なし” を区別するための用語かもしれないが、
そのような区別が有意になる箇所は見当たらない)。
】
これらの~APIは、[
`input$e 要素に対しては その`値$fe /
`textarea$e 要素に対しては その`~API値$fe
]に対し演算するモノトスル。
この,演算される値~文字列は、
以下に与える~algoにおいては,当の要素に
`関連な値@
と総称される。
◎
For input elements, these APIs must operate on the element's value. For textarea elements, these APIs must operate on the element's API value. In the below algorithms, we call the value string being operated on the relevant value.
`textarea$e 要素~用に`生の値$tAに代えて`~API値$feを利用することは、
文字 `000D^U `CR^cn が正規化されて消えることを意味する。
例えば:
◎
The use of API value instead of raw value for textarea elements means that U+000D (CR) characters are normalized away. For example,
`textFieldSelection-1^xCode
`生の値$tA `A\r\nB^l に演算した場合、
文字~並び `A\r^l が置換される結果 `replaced\nB^l になるが、
`~API値$fe `A\nB^l を利用するので,文字~並び `A\n^l が置換される結果 `replacedB^l になる。
◎
If we had operated on the raw value of "A\r\nB", then we would have replaced the characters "A\r", ending up with a result of "replaced\nB". But since we used the API value of "A\nB", we replaced the characters "A\n", giving "replacedB".
文字 `200D^U ZERO WIDTH JOINER
などの可視でない文字であっても,文字として数えられる。
したがって,一例として、
選択は 可視でない文字のみを含むこともあり,~text挿入~cursorは そのような文字の前後いずれかの側に配置され得る。
◎
Characters with no visible rendering, such as U+200D ZERO WIDTH JOINER, still count as characters. Thus, for instance, the selection can include just an invisible character, and the text insertion cursor can be placed to one side or another of such a character.
これらの~APIが適用される要素に対し,`関連な値$が変化したときは、
次を走らすとする:
◎
Whenever the relevant value changes for an element to which these APIs apply, run these steps:
-
~IF[
要素は`選択$を有する
]:
◎
If the element has a selection:
-
~IF[
選択の始端は `関連な値$の終端を過ぎている
]
⇒
選択の始端 ~SET `関連な値$の終端
◎
If the start of the selection is now past the end of the relevant value, set it to the end of the relevant value.
-
~IF[
選択の終端は `関連な値$の終端を過ぎている
]
⇒
選択の終端 ~SET `関連な値$の終端
◎
If the end of the selection is now past the end of the relevant value, set it to the end of the relevant value.
-
~IF[
~UAは空な選択を~supportしない
]~AND[
選択の始端, 終端とも`関連な値$の終端を指している
]
⇒
選択を除去した上で,要素の`~text手入力~cursor位置$ ~SET `関連な値$の終端
◎
If the user agent does not support empty selection, and both the start and end of the selection are now pointing to the end of the relevant value, then instead set the element's text entry cursor position to the end of the relevant value, removing any selection.
-
~ELSE( 要素は`~text手入力~cursor位置$を有する)
⇒
~IF[
`~text手入力~cursor位置$は `関連な値$の終端を過ぎている
]
⇒
`~text手入力~cursor位置$ ~SET `関連な値$の終端
◎
Otherwise, the element must have a text entry cursor position position. If it is now past the end of the relevant value, set it to the end of the relevant value.
注記:
上で切詰める手続きのみならず,この仕様の他所にも、
`関連な値$が変化するときに,`~text手入力~cursor位置$を改変する事例がある。
例えば `textarea$e 用の `value$m 設定子など。
◎
In some cases where the relevant value changes, other parts of the specification will also modify the text entry cursor position, beyond just the clamping steps above. For example, see the value setter for textarea.
[
`input$e / `textarea$e
]要素において~text`選択$を変更するような~UI特能は、
アリな所では,`選択~範囲を設定する$~algoを利用して実装するモノトスル
— 例えば すべてに同じ~eventが発火されるように。
◎
Where possible, user interface features for changing the text selection in input and textarea elements must be implemented using the set the selection range algorithm so that, e.g., all the same events fire.
各[
`input$e / `textarea$e
]要素の`選択$は、
次のいずれかを値にとる
`選択~方向@
を有する
⇒#
`forward^l,
`backward^l,
`none^l
◎
The selections of input and textarea elements have a selection direction, which is either "forward", "backward", or "none".\
選択~方向の正確な意味は~platformに依存する。
この方向は、
利用者が選択を操作するときに設定される。
`選択~方向$は、
初期~時は[
当の~platformが~supportするならば `none^l /
~ELSE_ `forward^l
]にするモノトスル。
◎
The exact meaning of the selection direction depends on the platform. This direction is set when the user manipulates the selection. The initial selection direction must be "none" if the platform supports that direction, or "forward" otherwise.
要素の
`選択~方向を設定する@
ときは、
所与の
( %方向 )
に対し,次を走らす
⇒
要素の`選択~方向$ ~SET [
次が満たされるならば `forward^l /
~ELSE_ %方向
]
⇒
[
%方向 ~EQ `none^l
]~AND[
~platformは %方向 を~supportしない
]
◎
To set the selection direction of an element to a given direction, update the element's selection direction to the given direction, unless the direction is "none" and the platform does not support that direction; in that case, update the element's selection direction to "forward".
注記:
Windows 上では、
この選択~方向は、
選択に相対的な~caret位置を指示する:
~caretは、
方向に応じて[
`forward^l ならば選択の終端 /
`backward^l ならば選択の始端
]にある。
Windows に `none^l 方向はない。
◎
On Windows, the direction indicates the position of the caret relative to the selection: a "forward" selection has the caret at the end of the selection and a "backward" selection has the caret at the start of the selection. Windows has no "none" direction.
Mac では、
方向は,利用者が
Shift + 矢印~UIkeyを利用して,選択~範囲を調整するときに 選択のどちらの端が影響されるかを指示する:
改変される端は、
方向に応じて[
`forward^l ならば選択の終端 /
`backward^l ならば選択の始端
]になる。
Mac では、
`none^l 方向が既定であり,特定0の方向はまだ選択されてないことを指示する。
方向は、
利用者が選択を最初に調整するときに,どっちの矢印~UIkeyが利用されたかに基づいて暗黙的に設定される。
◎
On Mac, the direction indicates which end of the selection is affected when the user adjusts the size of the selection using the arrow keys with the Shift modifier: the "forward" direction means the end of the selection is modified, and the "backward" direction means the start of the selection is modified. The "none" direction is the default on Mac, it indicates that no particular direction has yet been selected. The user sets the direction implicitly when first adjusting the selection, based on which directional arrow key was used.
`select()@m
~method~手続きは:
◎
The select() method, when invoked, must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[[
この~methodはコレに`適用されない$
]~OR[
コレに対応する~controlには選択-可能な~textはない
]]
⇒
~RET
◎
If this element is an input element, and either select() does not apply to this element or the corresponding control has no selectable text, return.
一例として、
`<input type=color>@~HEinput#color-state-(type=color)$e
を[
16 進~色~codeを受容する~text~control
]ではなく[
色~pickerを擁する~color-well
]として具現化する~UAにおいては、
選択-可能な~textは無いので,この~methodの~callは無視される。
◎
For instance, in a user agent where <input type=color> is rendered as a color well with a picker, as opposed to a text control accepting a hexadecimal color code, there would be no selectable text, and thus calls to the method are ignored.
-
コレの`選択~範囲を設定する$( 0, `無限大^i )
◎
Set the selection range with 0 and infinity.
`selectionStart@m
取得子~手続きは:
◎
The selectionStart attribute's getter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~RET ~NULL
◎
If this element is an input element, and selectionStart does not apply to this element, return null.
-
~IF[
コレは`選択$を有さない
]
⇒
~RET コレに`関連な値$の中で`~text手入力~cursor位置$を指す`~offset$
◎
If there is no selection, return the code unit offset within the relevant value to the character that immediately follows the text entry cursor.
-
~RET コレに`関連な値$の中で`選択$の始端を指す`~offset$
◎
Return the code unit offset within the relevant value to the character that immediately follows the start of the selection.
`selectionStart$m
設定子~手続きは:
◎
The selectionStart attribute's setter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~THROW `InvalidStateError$E
◎
If this element is an input element, and selectionStart does not apply to this element, throw an "InvalidStateError" DOMException.
-
%終端 ~LET コレ上の `selectionEnd$m 取得子~手続き()
◎
Let end be the value of this element's selectionEnd attribute.
-
~IF[
%終端 ~LT 所与の値
]
⇒
%終端 ~SET 所与の値
◎
If end is less than the given value, set end to the given value.
-
%方向 ~LET コレ上の `selectionDirection$m 取得子~手続き()
◎
↓
-
コレの`選択~範囲を設定する$( 所与の値, %終端, %方向 )
◎
Set the selection range with the given value, end, and the value of this element's selectionDirection attribute.
`selectionEnd@m
取得子~手続きは:
◎
The selectionEnd attribute's getter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~RET ~NULL
◎
If this element is an input element, and selectionEnd does not apply to this element, return null.
-
~IF[
コレは`選択$を有さない
]
⇒
~RET コレに`関連な値$の中で`~text手入力~cursor位置$を指す`~offset$
◎
If there is no selection, return the code unit offset within the relevant value to the character that immediately follows the text entry cursor.
-
~RET コレに`関連な値$の中で`選択$の終端を指す`~offset$
◎
Return the code unit offset within the relevant value to the character that immediately follows the end of the selection.
`selectionEnd$m
設定子~手続きは:
◎
The selectionEnd attribute's setter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~THROW `InvalidStateError$E
◎
If this element is an input element, and selectionEnd does not apply to this element, throw an "InvalidStateError" DOMException.
-
%始端 ~LET コレ上の `selectionStart$m 取得子~手続き()
◎
↓
-
%方向 ~LET コレ上の `selectionDirection$m 取得子~手続き()
◎
↓
-
コレの`選択~範囲を設定する$( %始端, 所与の値, %方向 )
◎
Set the selection range with the value of this element's selectionStart attribute, the given value, and the value of this element's selectionDirection attribute.
`selectionDirection@m
取得子~手続きは:
◎
The selectionDirection attribute's getter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~RET ~NULL
◎
If this element is an input element, and selectionDirection does not apply to this element, return null.
-
~RET コレの`選択~方向$
◎
Return this element's selection direction.
`selectionDirection$m
設定子~手続きは:
◎
The selectionDirection attribute's setter must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~THROW `InvalidStateError$E
◎
If this element is an input element, and selectionDirection does not apply to this element, throw an "InvalidStateError" DOMException.
-
%始端 ~LET コレ上の `selectionStart$m 取得子~手続き()
◎
↓
-
%終端 ~LET コレ上の `selectionEnd$m 取得子~手続き()
◎
↓
-
コレの`選択~範囲を設定する$( %始端, %終端, 所与の値 )
◎
Set the selection range with the value of this element's selectionStart attribute, the value of this element's selectionEnd attribute, and the given value.
`setSelectionRange(start, end, direction)@m
~method~手続きは:
◎
The setSelectionRange(start, end, direction) method, when invoked, must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~THROW `InvalidStateError$E
◎
If this element is an input element, and setSelectionRange() does not apply to this element, throw an "InvalidStateError" DOMException.
-
コレの`選択~範囲を設定する$( %start, %end, %direction )
◎
Set the selection range with start, end, and direction.
~text~control【を表現する要素】 %要素 の
`選択~範囲を設定する@
ときは、
所与の
⇒#
%始端 (負でない整数, ~NULL のいずれか),
%終端 (負でない整数, ~NULL, `無限大^i のいずれか),
%方向 (文字列, 省略時は ε)
◎終
に対し,次の手続き走らす
— 以下においては、
値 `無限大^i は他のどの値よりも大きいとする:
◎
To set the selection range with an integer or null start, an integer or null or the special value infinity end, and optionally a string direction, run the following steps:
-
~IF[
%始端 ~EQ ~NULL
]
⇒
%始端 ~SET 0
◎
If start is null, let start be zero.
-
~IF[
%終端 ~EQ ~NULL
]
⇒
%終端 ~LET 0
◎
If end is null, let end be zero.
-
%L ~LET %要素 に`関連な値$の`長さ$
◎
↓
-
%終端 ~LET { %終端, %L } の最小
◎
↓
-
%始端 ~LET { %始端, %L, %終端 } の最小
◎
↓
-
%要素 に`関連な値$の中で,`選択$の範囲を[
%始端 `~offset$ 〜 %終端 `~offset$
]に設定する
— 範囲が空になる場合、
空~選択の概念がない~UAにおいては,~cursorを %終端 `~offset$に設定する
◎
Set the selection of the text control to the sequence of code units within the relevant value starting with the code unit at the startth position (in logical order) and ending with the code unit at the (end-1)th position. Arguments greater than the length of the relevant value of the text control (including the special value infinity) must be treated as pointing at the end of the text control. If end is less than or equal to start then the start of the selection and the end of the selection must both be placed immediately before the character with offset end. In UAs where there is no concept of an empty selection, this must set the cursor to be just before the character with offset end.
-
~IF[
%方向 ~NIN【!identical】 { `backward^l, `forward^l }
]~OR[
%方向 ~EQ ε
]
⇒
%方向 ~SET `none^l
◎
If direction is not identical to either "backward" or "forward", or if the direction argument was not given, set direction to "none".
-
%要素 の`選択~方向を設定する$( %方向 )
◎
Set the selection direction of the text control to direction.
-
~IF[
前~段までにより,~text~controlの`選択$は改変された(その範囲, `選択~方向$いずれにせよ)
]
⇒
`要素~taskを~queueする$( `利用者~対話~task~source$, %要素, 次の手続き )
◎
If the previous steps caused the selection of the text control to be modified (in either extent or direction), then queue an element task on the user interaction task source given the element to\
手続きは
⇒
`~eventを発火する$( %要素, `select$et )
— 次のように初期化して
⇒
`bubbles$m 属性 ~SET ~T
◎
fire an event named select at the element, with the bubbles attribute initialized to true.
`setRangeText(replacement, start, end, selectionMode)@m
~method~手続きは:
◎
The setRangeText(replacement, start, end, selectMode) method, when invoked, must run the following steps:
-
~IF[
コレは `input$e 要素である
]~AND[
この~methodはコレに`適用されない$
]
⇒
~THROW `InvalidStateError$E
◎
If this element is an input element, and setRangeText() does not apply to this element, throw an "InvalidStateError" DOMException.
-
コレの`値は~dirtyか$fe ~SET ~T
◎
Set this element's dirty value flag to true.
-
%選択~始端 ~LET コレ上の `selectionStart$m 取得子~手続き()
◎
↓
-
%選択~終端 ~LET コレ上の `selectionEnd$m 取得子~手続き()
◎
↓
-
~IF[
%start 以降の引数は与えられていない
]
⇒#
( %start, %end ) ~SET ( %選択~始端, %選択~終端 );
%selectionMode ~SET `preserve$l
◎
If the method has only one argument, then let start and end have the values of the selectionStart attribute and the selectionEnd attribute respectively.
◎
Otherwise, let start, end have the values of the second and third arguments respectively.
◎
↓↓
-
~IF[
%start ~GT %end
]
⇒
~THROW `IndexSizeError$E
◎
If start is greater than end, then throw an "IndexSizeError" DOMException.
-
%L ~LET コレに`関連な値$の長さ
◎
↓
-
%始端 ~SET { %start, %L } の最小
◎
If start is greater than the length of the relevant value of the text control, then set it to the length of the relevant value of the text control.
-
%終端 ~SET { %end, %L } の最小
◎
If end is greater than the length of the relevant value of the text control, then set it to the length of the relevant value of the text control.
◎
↑↑Let selection start be the current value of the selectionStart attribute.
◎
↑↑Let selection end be the current value of the selectionEnd attribute.
-
~IF[
%始端 ~LT %終端
]
⇒
コレに`関連な値$から範囲[
%始端 `~offset$ 〜 %終端 `~offset$
]にある`符号単位$を削除する
◎
If start is less than end, delete the sequence of code units within the element's relevant value starting with the code unit at the startth position and ending with the code unit at the (end-1)th position.
-
コレに`関連な値$の %始端 `~offset$に %replacement の値を挿入する
◎
Insert the value of the first argument into the text of the relevant value of the text control, immediately before the startth code unit.
-
%新~終端 ~LET %始端 + ( %replacement の`長さ$ )
◎
Let new length be the length of the value of the first argument.
◎
Let new end be the sum of start and new length.
-
%selectionMode に応じて:
◎
Run the appropriate set of substeps from the following list:
- `select@l
◎
If the fourth argument's value is "select"
-
( %選択~始端, %選択~終端 ) ~SET ( %始端, %新~終端 )
◎
Let selection start be start.
◎
Let selection end be new end.
- `start@l
◎
If the fourth argument's value is "start"
-
( %選択~始端, %選択~終端 ) ~SET ( %始端, %始端 )
◎
Let selection start and selection end be start.
- `end@l
◎
If the fourth argument's value is "end"
-
( %選択~始端, %選択~終端 ) ~SET ( %新~終端, %新~終端 )
◎
Let selection start and selection end be new end.
- `preserve@l
◎
If the fourth argument's value is "preserve"
◎
↑↑If the method has only one argument
-
-
%差分 ~LET ( %replacement の長さ ) − ( %終端 − %始端 )
◎
Let old length be end minus start.
◎
Let delta be new length minus old length.
-
~IF[
%選択~始端 ~GT %終端
]
⇒
%選択~始端 ~INCBY %差分
( %差分 が負である場合,すなわち 新たな~textが置換された~textより短い場合、
%選択~始端 の値は減ることになる)
◎
If selection start is greater than end, then increment it by delta. (If delta is negative, i.e. the new text is shorter than the old text, then this will decrease the value of selection start.)
-
~ELIF[
%選択~始端 ~GT %始端
]
⇒
%選択~始端 ~SET %始端
( %選択~始端 が置換された~textの途中にあった場合,選択の始端は新たな~textの始端に留められる)
◎
Otherwise: if selection start is greater than start, then set it to start. (This snaps the start of the selection to the start of the new text if it was in the middle of the text that it replaced.)
-
~IF[
%選択~終端 ~GT %終端
]
⇒
%選択~終端 ~INCBY %差分
◎
If selection end is greater than end, then increment it by delta in the same way.
-
~ELIF[
%選択~終端 ~GT %始端
]
⇒
%選択~終端 ~SET %新~終端
( %選択~終端 が置換された~textの途中にあった場合,選択の始端は新たな~textの終端に留められる)
◎
Otherwise: if selection end is greater than start, then set it to new end. (This snaps the end of the selection to the end of the new text if it was in the middle of the text that it replaced.)
-
コレの`選択~範囲を設定する$( %選択~始端, %選択~終端 )
◎
Set the selection range with selection start and selection end.
`setRangeText()$m
~methodは、
次の列挙を利用する:
◎
The setRangeText() method uses the following enumeration:
enum `SelectionMode@I {
`select$l,
`start$l,
`end$l,
`preserve$l //
};
現在~選択されている~textを得するには、
次の~JSで足りる:
◎
To obtain the currently selected text, the following JavaScript suffices:
var %selectionText = %control.value.substring(%control.selectionStart, %control.selectionEnd);
( %control は[
`input$e / `textarea$e
]要素とする。)
◎
...where control is the input or textarea element.
3 つの属性を保全して,~text選択は保守しながら、
~text~controlの始端に~textを追加する例:
◎
To add some text at the start of a text control, while maintaining the text selection, the three attributes must be preserved:
var %oldStart = %control.selectionStart;
var %oldEnd = %control.selectionEnd;
var %oldDirection = %control.selectionDirection;
var %prefix = "http://";
%control.value = %prefix + %control.value;
%control.setSelectionRange(%oldStart + %prefix.length, %oldEnd + %prefix.length, %oldDirection);
( %control は[
`input$e / `textarea$e
]要素とする。)
◎
...where control is the input or textarea element.