1. 基盤
この仕様は Infra Standard `INFRA$r に依存する。 ◎ This specification depends on the Infra Standard. [INFRA]
この仕様の一部の用語は `Encoding^cite, `Selectors^cite, `Web IDL^cite, `XML^cite, `Namespaces in XML^cite にて定義される。 `ENCODING$r `SELECTORS4$r `WEBIDL$r `XML$r `XML-NAMES$r ◎ Some of the terms used in this specification are defined in Encoding, Selectors, Web IDL, XML, and Namespaces in XML. [ENCODING] [SELECTORS4] [WEBIDL] [XML] [XML-NAMES]
語 `文脈~obj@ ( `context object^en )は、`コレ$の別名である。 ◎ The term context object is an alias for this.
注記: `文脈~obj$の利用eは、 “コレ” の支持を受けて非推奨にされた。 【この~siteの和訳では、すべて “コレ” に統一済み。】 ◎ Usage of context object is deprecated in favor of this.
拡張が必要になったときは、それに則って~DOM標準が更新されるか,あるいは `適用-可能な仕様@† 用に供される拡張用~hookを利用するような,新たな標準が書かれ得る。 ◎ When extensions are needed, the DOM Standard can be updated accordingly, or a new standard can be written that hooks into the provided extensibility hooks for applicable specifications.
【† `HTML$r に定義される同じ名前の用語と同様 — この仕様~自身も含まれる。 】
【この訳に特有な表記規約】
この訳では,以下の表記が用いられる:
- ~algoや定義の記述に利用されている各種記号( ε, ~LET, ~EQ, ~IF, ~EACH(…), ~RET, ~THROW, 等々)の意味や定義の詳細は、~SYMBOL_DEF_REFを~~参照されたし。
- 所与の[ 有限個の~objからなる有順序~集合(例えば`~tree$や~list)の部分集合(例えば ある条件を満たすものなど) ] %S に対し,その[ `最初のもの?@ / `最後のもの?@ ]とは、 %S が空(例えば,条件を満たす~objが存在しない)ならば ~NULL であり,そうでなければ その順序において %S の中で[ 最初 / 最後 ]に在る~objとする。 ( “最初” / “最後” がこの意味で用いられる所( ~NULL にもなり得る所)では、常に( WebIDL 方式に倣って) "?" が付記される。 )
- 整数 %index に対する “%index 番” は 0 番から数えるとする。
1.1. ~tree
`~tree@ とは、有限かつ階層的な~tree構造である。 `~tree順序@ は、深優先前順走査に基づく。 ◎ A tree is a finite hierarchical tree structure. In tree order is preorder, depth-first traversal of a tree.
【 `深さ優先^_, `前順^_ 】: この方式による~treeの走査-は、~HTMLや~XML文書の~source~text表現における,要素の開始~tagや~text内容(より一般には`文字~data~node$)が現れる順序を表現する(ゆえに, “文書~順序” と称されることもある)。
例えば、次の~source(単純にするため, `e^e 要素と~text内容のみからなる)から生成される~DOM~treeは:
<e><e></e>~sourceに<e>現れる<e>順序が</e><e>そのまま<e>~tree順序に</e></e>なる</e></e>
次のような模式図として可視化できる:
`[ [ ] (~sourceに) [ (現れる) [ (順序が) ] [ (そのまま) [ (~tree順序に) ] ] (なる) ] ]^bpex図の左端が~sourceの先頭, 右端が末尾に対応する。 図の横線が,~treeの中の各~nodeとそれが~source内を占める~~範囲(要素の開始~tag〜終了~tag / 文字~dataの先頭〜末尾)を表し、それらの上下関係が~treeの階層(~nodeの入子ng階層)を表す。 図の中の各~文字は文字~dataの各~文字に対応し,それらが成す各~COLOR_Rが`文字~data~node$が占める~~範囲を表す。 ~nodeの順序はこれらの横線の左端の位置から決定される。 最上層の横線がこの~treeの根~node(根元)を表し,この順序における先頭になる。
`~tree$に `関与して@ いる各~objは、~objまたは~NULL をとる `親@ を持ち, 0 個以上の~objからなる`有順序~集合$を成す `子たち@ を持つ。 ~obj %A の`親$ %B ~NEQ ~NULL ならば, %A は %B の`子$である。 ◎ An object that participates in a tree has a parent, which is either null or an object, and has children, which is an ordered set of objects. An object A whose parent is object B is a child of B.
【 %A は %B の “子である” という句は、[ %A ~IN %B の`子たち$ ]を意味する。 】【 %B は “子を持つ” という句は、[ %B の`子たち$は`空$でない ]ことを意味する。 】【 同じ~objが同時に複数の~objの子になることはない。 】
~objの `根@ とは、[ ~objの`親$ ~EQ ~NULL ]ならば~obj自身であり,他の場合は~objの`親$の`根$である。 `~tree$の`根$は、その`~tree$に`関与して$いる~objであって,[ `親$ ~EQ ~NULL ]なるものである。 ◎ The root of an object is itself, if its parent is null, or else it is the root of its parent. The root of a tree is any object participating in that tree whose parent is null.
【 この定義は、`親$を順々に辿った結果は循環しない(自身には戻らない)ことも含意している。 同様に,`子$を順々に辿った結果も循環しない。 】
~obj %A が~obj %B の `子孫@ であるとは、次を意味する ⇒ [ %A は %B の`子$である ]~OR[ %A は %B のある`子孫$の`子$である ] ◎ An object A is called a descendant of an object B, if either A is a child of B or A is a child of an object C that is a descendant of B.
【 上述したように循環しないので、 %A 自身が %A の`子孫$になることはない。 】
~obj %A が~obj %B の `広義子孫@ であるとは、次を意味する ⇒ [ %A ~EQ %B ]~OR[ %A は %B の`子孫$である ] ◎ An inclusive descendant is an object or one of its descendants.
【 “広義” という対訳は,よいとは言えないが、より忠実に “自身も含めた子孫” などと訳すのでは,用語として定義する意義 — 他から簡潔に参照できるようにする — も失われる(単に “自身または子孫” と記すのと同じことになる)。 】
~obj %A が~obj %B の `先祖@ であるとは、次を意味する ⇒ %B は %A の`子孫$である ◎ An object A is called an ancestor of an object B if and only if B is a descendant of A.
~obj %A が~obj %B の `広義先祖@ であるとは、次を意味する ⇒ [ %A ~EQ %B ]~OR[ %A は %B の`先祖$である ] ◎ An inclusive ancestor is an object or one of its ancestors.
~obj %A が~obj %B の `同胞@ ( “兄弟” )であるとは、次を意味する ⇒ [ %A の`親$ ~NEQ ~NULL ]~AND[ %A の`親$ ~EQ %B の`親$ ] ◎ An object A is called a sibling of an object B, if and only if B and A share the same non-null parent.
【 定義により, %A 自身も 親が非~NULLならば %A の`同胞$になる。 この仕様の中では、この点について特に注意を要する箇所は(現時点では)ないが。 例えば、この同胞の定義を “%A と %B は同じでない” と解釈したとしても,この仕様の残りの部分には影響しない。 】
~obj %A が~obj %B の `広義同胞@ であるとは、次を意味する ⇒ [ %A ~EQ %B ]~OR[ %A は %B の`同胞$である ] ◎ An inclusive sibling is an object or one of its siblings.
【 %A 自身は,親が~NULLであっても %A の広義同胞になる点で、`同胞$の定義と異なる。 この定義は、もっぱら他の仕様~用にあり,この仕様~内では利用されない。 】
【! https://github.com/whatwg/dom/issues/55 】~obj %A が~obj %B に `先行-@ するとは、次を意味する ⇒ [ %A と %B は同じ`~tree$に関与する ]~AND[ `~tree順序$において %A は %B より前に在る ] ◎ An object A is preceding an object B if A and B are in the same tree and A comes before B in tree order.
~obj %A が~obj %B に `後続-@ するとは、次を意味する ⇒ [ %A と %B は同じ`~tree$に関与する ]~AND[ `~tree順序$において %A は %B より後に在る ] ◎ An object A is following an object B if A and B are in the same tree and A comes after B in tree order.
~objの `最初の子?@ とは、~objの`子$のうち,`最初のもの?$である。 ◎ The first child of an object is its first child or null if it has no children.
~objの `最後の子?@ とは、~objの`子$のうち,`最後のもの?$である。 ◎ The last child of an object is its last child or null if it has no children.
~objの `前-同胞?@ とは、~objに`先行-$する`同胞$のうち,`最後のもの?$である。 ◎ The previous sibling of an object is its first preceding sibling or null if it has no preceding sibling.
~objの `次-同胞?@ とは、~objに`後続-$する`同胞$のうち,`最初のもの?$である。 ◎ The next sibling of an object is its first following sibling or null if it has no following sibling.
~objの `~index@ とは、~objに`先行-$する`同胞$の個数である(なければ 0 になる)。 ◎ The index of an object is its number of preceding siblings, or 0 if it has none.
1.2. 有順序~集合
文字列 %入力 を `有順序~集合 構文解析器@ にかけるときは、次を走らす: ◎ The ordered set parser takes a string input and then runs these steps:
- %入力~token列 ~LET `~ASCII空白で分割する$( %入力 ) ◎ Let inputTokens be the result of splitting input on ASCII whitespace.
- %~token列 ~LET 新たな`有順序~集合$ ◎ Let tokens be a new ordered set.
- %入力~token列 内の ~EACH( %~token ) に対し ⇒ %~token列 に %~token を`付加する$set ◎ For each token in inputTokens, append token to tokens.
- ~RET %~token列 ◎ Return tokens.
文字列からなる有順序~集合 %S を `有順序~集合 直列化器@ にかけるときは、 %S を~U0020で`連結-$した結果を返す。 ◎ The ordered set serializer takes a set and returns the concatenation of set using U+0020 SPACE.
1.3. 選択子
%node の `視野の下で選択子を照合する@ ときは、所与の ( 文字列 %選択子 ) に対し,次を走らす: ◎ To scope-match a selectors string selectors against a node, run these steps:
- %S ~LET `選択子として構文解析する$( %選択子 ) `SELECTORS4$r ◎ Let s be the result of parse a selector selectors. [SELECTORS4]
- ~IF[ %S ~EQ `失敗^i ] ⇒ ~THROW `SyntaxError$E ◎ If s is failure, then throw a "SyntaxError" DOMException.
- ~RET `~treeに対し選択子を照合する$( 選択子 %S, 根~要素たち %node の`根$, `視野ng根$ %node ) `SELECTORS4$r ◎ Return the result of match a selector against a tree with s and node’s root using scoping root node. [SELECTORS4].
注記: 選択子の中の~ns用の~supportは、計画されておらず,追加されることはない。 ◎ Support for namespaces within selectors is not planned and will not be added.
1.4. ~ns
`有修飾~名として検証する@ ときは、所与の ( %名前 ) に対し,次を走らす ⇒ ~IF[ %名前 は `QName$prod 生成規則に合致しない ] ⇒ ~THROW `InvalidCharacterError$E ◎ To validate a qualifiedName, throw an "InvalidCharacterError" DOMException if qualifiedName does not match the QName production.
`検証して抽出する@ ときは、所与の ( %~ns, %名前 ) に対し,次を走らす: ◎ To validate and extract a namespace and qualifiedName, run these steps:
- ~IF[ %~ns ~EQ 空~文字列 ] ⇒ %~ns ~SET ~NULL ◎ If namespace is the empty string, set it to null.
- `有修飾~名として検証する$( %名前 ) ◎ Validate qualifiedName.
- %接頭辞 ~LET ~NULL ◎ Let prefix be null.
- %局所~名 ~LET %名前 ◎ Let localName be qualifiedName.
- ~IF[ %名前 は `:^l (~U003A) を含む 【 `PrefixedName$prod 生成規則に合致する】 ] ⇒ ( %接頭辞, %局所~名 ) ~SET %名前 をそこで分割して得られる ( 前の部分, 後の部分 ) ◎ If qualifiedName contains a ":" (U+003E), then split the string on it and set prefix to the part before and localName to the part after.
-
~IF[ 次のいずれかが満たされる ]…: ◎ ↓
- [ %~ns ~EQ ~NULL ]~AND[ %接頭辞 ~NEQ ~NULL ] ◎ If prefix is non-null and namespace is null, then throw a "NamespaceError" DOMException.
- [ %~ns ~NEQ `~XML~ns$ ]~AND[ %接頭辞 ~EQ `xml^l ] ◎ If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException.
- [ %~ns ~NEQ `~XMLNS~ns$ ]~AND[[ %名前 ~EQ `xmlns^l ]~OR[ %接頭辞 ~EQ `xmlns^l ]] ◎ If either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace, then throw a "NamespaceError" DOMException.
- [ %~ns ~EQ `~XMLNS~ns$ ]~AND[ %名前 ~NEQ `xmlns^l ]~AND[ %接頭辞 ~NEQ `xmlns^l ] ◎ If namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns", then throw a "NamespaceError" DOMException.
…ならば ⇒ ~THROW `NamespaceError$E ◎ ↑
- ~RET ( %~ns, %接頭辞, %局所~名 ) ◎ Return namespace, prefix, and localName.
2. ~event
2.1. “DOM Events” 序論
~web~platformを全体を通して、`~event$は — 何かが生じたことを通達するために — ~objに向けて`配送-$される — ~network活動や利用者とのヤリトリなど。 これらの~objは $EventTarget ~interfaceを実装し, その $addEventListener() を~callすることにより `~event$を観測するための`~event~listener$を追加できる: ◎ Throughout the web platform events are dispatched to objects to signal an occurrence, such as network activity or user interaction. These objects implement the EventTarget interface and can therefore add event listeners to observe events by calling addEventListener():
%obj.addEventListener("load", imgFetched)
function imgFetched(%ev) {
// 成功裡に load できた
…
}
`~event~listener$は、次のいずれかにより除去できる: ◎ ↓
- $removeEventListener() ~methodに $addEventListener() と同じ引数たちを渡すことにより。 ◎ Event listeners can be removed by utilizing the removeEventListener() method, passing the same arguments.
- $addEventListener() に[ ある $@AbortController %controller の`通達$aB【!$AbortSignal】 ]を渡して, %controller の $abort() を~callすることにより。 ◎ Alternatively, event listeners can be removed by passing an AbortSignal to addEventListener() and calling abort() on the controller owning the signal.
`~event$もまた~objであり, $Event ~interface(またはその派生d~interface)を実装する。 上の例では、 %ev が`~event$である。 %ev は、`~event~listener$の `callback$evL (概して上に示したような~JS Function )に引数として渡される。 `~event~listener$は、まず,`~event$の $type 属性~値(上の例では `load^l )をその~~制御に利用する。 `~event$の $target 属性~値は`~event$の`配送-$先の~obj(上の例の %obj )を返す。 ◎ Events are objects too and implement the Event interface (or a derived interface). In the example above ev is the event. ev is passed as an argument to the event listener’s callback (typically a JavaScript Function as shown above). Event listeners key off the event’s type attribute value ("load" in the above example). The event’s target attribute value returns the object to which the event was dispatched (obj above).
`~event$は、概して,利用者とのヤリトリや何らかの~task完了の結果,~UAにより`配送-$されるが、~app自身も,合成な~eventと共通的に称されるものを利用して`~event$を`配送-$できる: ◎ Although events are typically dispatched by the user agent as the result of user interaction or the completion of some task, applications can dispatch events themselves by using what are commonly known as synthetic events:
// ~custom~event~listenerを追加する obj.addEventListener("cat", function(%e) { process(%e.detail) }) // ~eventを作成して配送する var %event = new CustomEvent("cat", {"detail":{"hazcheeseburger":true}}) %obj.dispatchEvent(%event)
通達-時の他にも、`~event$は,演算の中で次に起きる出来事を~appに制御させる~~目的で利用されることがある。 例えば,~form提出の一環として、 $type 属性が `submit^l にされた`~event$が`配送-$される。 この`~event$の $preventDefault() ~methodが呼出されると,~formは提出されずに終了されることになる。 ~appにより`配送-$される`~event$(合成な~event)を通して,この機能性を利用する場合、 $EventTarget.dispatchEvent() ~methodの返り値も利用できる: ◎ Apart from signaling, events are sometimes also used to let an application control what happens next in an operation. For instance as part of form submission an event whose type attribute value is "submit" is dispatched. If this event’s preventDefault() method is invoked, form submission will be terminated. Applications who wish to make use of this functionality through events dispatched by the application (synthetic events) can make use of the return value of the dispatchEvent() method:
if(%obj.dispatchEvent(%event)) {
// ~eventは取消されなかった。手品の時間だ。
…
}
`~event$が`~tree$に`関与して$いる~obj(例えば`要素$)に向けて`配送-$される場合、その~eventは,その~objの`先祖$の`~event~listener$にも到達し得る: ◎ When an event is dispatched to an object that participates in a tree (e.g., an element), it can reach event listeners on that object’s ancestors too.\
- まず、~objの各 `広義先祖$に対し,`~tree順序$で ⇒ その`~event~listener$†のうち[ `capture$evLが ~T にされているもの ]が呼出される ◎ Effectively, all the object’s inclusive ancestor event listeners whose capture is true are invoked, in tree order.\
- 次に,[ `~event$の $bubbles ~EQ ~T ]ならば、~objの各 `広義先祖$に対し,今度は`~tree順序$の逆順で ⇒ その`~event~listener$†のうち[ `capture$evLが ~F にされているもの ]が呼出される ◎ And then, if event’s bubbles is true, all the object’s inclusive ancestor event listeners whose capture is false are invoked, now in reverse tree order.
【† 当の広義先祖の`~event~listener~list$内の`~event~listener$のうち,その `type$evL は `~event$の $type に合致するもの。 該当する~event~listenerが呼出される順序は、この~listが管理する。 】
`~event$が`~tree$内で働く様子を例で示す: ◎ Let’s look at an example of how events work in a tree:
<!doctype html>
<html>
<head>
<title>つまらない例</title>
</head>
<body>
<p>Hello <span id=x>world</span>!</p>
<script>
function test(%e) {
debug(%e.target, %e.currentTarget, %e.eventPhase); // A
}
document.addEventListener("hey", test, {capture: true}); // B
document.body.addEventListener("hey", test); // C
var %ev = new Event("hey", {bubbles:true})
document.getElementById("x").dispatchEvent(%ev);
</script>
</body>
</html>
`debug^c 関数(A)は 2 回~呼出されることになる。 2 回とも、`~event$の $target 属性~値は `span^c `要素$ になる。 1 回目での $currentTarget 属性~値は`文書$になり(B), $eventPhase 属性の値が $CAPTURING_PHASE から $BUBBLING_PHASE に切り替わった後, 2 回目では `body^e `要素$になる(C)。 もし`~event~listener$が `span^e `要素$にも登録されていたなら、$eventPhase 属性の値は $AT_TARGET にも切り替わることになる。 ◎ The debug function will be invoked twice. Each time the event’s target attribute value will be the span element. The first time currentTarget attribute’s value will be the document, the second time the body element. eventPhase attribute’s value switches from CAPTURING_PHASE to BUBBLING_PHASE. If an event listener was registered for the span element, eventPhase attribute’s value would have been AT_TARGET.
2.2. ^@Event ~interface
!! [`Exposed$=(Window,Worker,AudioWorklet)] interface @Event { `Event$mc($DOMString %type, optional $EventInit %eventInitDict = {}); ~RA $DOMString $type; ~RA $EventTarget? $target; ~RA $EventTarget? $srcElement; // 旧来 ~RA $EventTarget? $currentTarget; $sequence<$EventTarget> $composedPath(); const `unsigned short$ $NONE = 0; const `unsigned short$ $CAPTURING_PHASE = 1; const `unsigned short$ $AT_TARGET = 2; const `unsigned short$ $BUBBLING_PHASE = 3; ~RA `unsigned short$ $eventPhase; $undefined $stopPropagation(); attribute $boolean $cancelBubble; // `stopPropagation()^c の旧来の別名 $undefined $stopImmediatePropagation(); ~RA $boolean $bubbles; ~RA $boolean $cancelable; attribute $boolean $returnValue; // $undefined $preventDefault(); ~RA $boolean $defaultPrevented; ~RA $boolean $composed; [`LegacyUnforgeable$] ~RA $boolean $isTrusted; ~RA $DOMHighResTimeStamp $timeStamp; $undefined $initEvent($DOMString %type, optional $boolean %bubbles = false, optional $boolean %cancelable = false); // }; dictionary @EventInit { $boolean @EventInit.bubbles = false; $boolean @EventInit.cancelable = false; $boolean @EventInit.composed = false; }; !$Event ~objは、単に `~event@ とも称される。 それは、何かが生じたとき,それを通達できるようにする — 例えば、画像を~downloadが完了したときなど。 ◎ An Event object is simply named an event. It allows for signaling that something has occurred, e.g., that an image has completed downloading.
`~event~targetになり得るもの@ は、 ~NULL または $EventTarget ~objである。 ◎ A potential event target is null or an EventTarget object.
各`~event$には、次に挙げるものが結付けられる: ◎ ↓
- `~target@
- `~event~targetになり得るもの$。 他が言明されない限り, ~NULL とする。 ◎ An event has an associated target (a potential event target). Unless stated otherwise it is null.
- `関係d~target@
- `~event~targetになり得るもの$。 他が言明されない限り, ~NULL とする。 ◎ An event has an associated relatedTarget (a potential event target). Unless stated otherwise it is null.
- 注記: 他の仕様は ^relatedTarget 属性を定義するときに `関係d~target$を利用する。 `UIEVENTS$r ◎ Other specifications use relatedTarget to define a relatedTarget attribute. [UIEVENTS]
- `~touch~target~list@
- 0 個~以上の`~event~targetになり得るもの$からなる`~list$。 他が言明されない限り,空~listとする。 ◎ An event has an associated touch target list (a list of zero or more potential event targets). Unless stated otherwise it is the empty list.
- 注記: `~touch~target~list$は、もっぱら $TouchEvent ~interfaceとそれに関係する~interfaceを定義するために利用される。 `TOUCH-EVENTS$r ◎ The touch target list is for the exclusive use of defining the TouchEvent interface and related interfaces. [TOUCH-EVENTS]
- `経路@
-
0 個~以上の`構造体$からなる`~list$であり、初期~時は空とする。 それを成す各 `構造体$は次に挙げるものからなる:
- `呼出n~target@evP
- $EventTarget ~obj。
- `呼出n~targetは~shadow~tree内?@evP
- 真偽値。
- `~shadow調整-済み~target@evP
- `~event~targetになり得るもの$
- `関係d~target@evP
- `~event~targetになり得るもの$
- `~touch~target~list@evP
- 0 個以上の`~event~targetになり得るもの$からなる`~list$
- `閉な~treeの根?@evP
- 真偽値。
- `~slotは閉な~tree内?@evP
- 真偽値。
- %event = $Event(type [, eventInitDict])
- $type 属性~値が %type にされた,新たな %event を返す。 %eventInitDict 引数により,[ $bubbles / $cancelable ]属性も — 同じ名前の~obj~memberを介して — 設定できる。 ◎ Returns a new event whose type attribute value is set to type. The eventInitDict argument allows for setting the bubbles and cancelable attributes via object members of the same name.
- %event . $type
- %event の型を返す。 例えば `click^l, `hashchange^l, `submit^l など。 ◎ Returns the type of event, e.g. "click", "hashchange", or "submit".
- %event . $target
- %event の`配送-$先の~obj( %event の`~target$ )を返す。 ◎ Returns the object to which event is dispatched (its target).
- %event . $currentTarget
- 現在~呼出されている `callback$evL を持つ`~event~listener$が登録されている~objを返す。 ◎ Returns the object whose event listener’s callback is currently being invoked.
- %event . $composedPath()
- %event の`経路$内に在る各 `呼出n~target$evP ~obj(それ上で~listenerが呼出される~obj)からなる~listを返す — ただし、[ `~shadow根$の`~mode$sR ~EQ `closed^l ]なる`~shadow~tree$内の`~node$であって, %event の $currentTarget からは到達できないものは、返り値から除かれる。 ◎ Returns the invocation target objects of event’s path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root’s mode is "closed" that are not reachable from event’s currentTarget.
- %event . $eventPhase
- `~event$の相 — 次ののいずれかを返す ⇒# $NONE, $CAPTURING_PHASE, $AT_TARGET, $BUBBLING_PHASE ◎ Returns the event’s phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
- %event . $stopPropagation()
- `~tree$ 内に`配送-$されているとき、この~methodを呼出すことにより,現在の~obj以外の~objには %event が到達しないようになる。 ◎ When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
- %event . $stopImmediatePropagation()
- この~methodを呼出すことにより、 %event は 現在の~listenerを走り終えた後に[ それまでに登録された`~event~listener$ ]には到達しなくなり、`~tree$ 内に`配送-$されたときには, %event は他のどの~objにも到達しなくなる。 ◎ Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
- %event . $bubbles
- %event がどう初期化されたかに応じて,~T か~F を返す。 %event がその`~target$の`先祖$へ`~tree順序$の逆順にも遡る場合は ~T を返し, 他の場合は~F を返す。 ◎ Returns true or false depending on how event was initialized. True if event goes through its target’s ancestors in reverse tree order, and false otherwise.
- %event . $cancelable
- %event がどう初期化されたかに応じて,~T か ~F を返す。 その返り値は常に意味を持つとは限らないが、~T の場合, %event が`配送-$されている間の演算は $preventDefault() ~methodを呼出すことにより取消せることを指示し得る。 ◎ Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
- %event . $preventDefault()
- %event の $cancelable 属性~値が ~T にされている下で,[ $AddEventListenerOptions.passive が ~F に設定された %event ]用の~listenerの実行-中に呼出された場合、 %event が取消される必要がある旨をその`配送-$ 演算に通達する。 ◎ If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
- %event . $defaultPrevented
- ~T は、 $preventDefault() が呼出され, 成功裡に取消されたことを指示する。 他の場合は ~F を返す。 ◎ Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
- %event . $composed
- %event がどう初期化されたかに依存して ~T か ~F を返す。 [ %event の`~target$の`根$が $ShadowRoot `~node$である ]ときに,その~nodeを過ぎた先†に在る~listenerも呼出す場合は ~T になり、他の場合は ~F になる。 ◎ Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
- 【† %~event の`経路$が、`~shadow根$の`~host$を通して別の`~node~tree$へつながるように,構成される。 】
- %event . $isTrusted
- %event が~UA から`配送-$されたものである場合は ~T を, 他の場合は ~F を返す。 ◎ Returns true if event was dispatched by the user agent, and false otherwise.
- %event . $timeStamp
- %event の時刻印を`時刻起点$からのミリ秒数で返す。 ◎ Returns the event’s timestamp as the number of milliseconds measured relative to the time origin.
@type 取得子~手続きは、初期化-時の値を返す。 `~event$の作成-時には、この属性は空~文字列に初期化するモノトスル。 ◎ The type attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the empty string.
@currentTarget 取得子~手続きは、初期化-時の値を返す。 ◎ The currentTarget attribute must return the value it was initialized to.\
`~event$の作成-時には、この属性は ~NULL に初期化するモノトスル。 ◎ When an event is created the attribute must be initialized to null.
@composedPath() ~method~手続きは: ◎ The composedPath() method, when invoked, must run these steps:
- %~composed経路 ~LET 空`~list$ ◎ Let composedPath be an empty list.
- %経路 ~LET コレの`経路$ ◎ Let path be this’s path.
- ~IF[ %経路 は`空$である ] ⇒ ~RET %~composed経路 ◎ If path is empty, then return composedPath.
- %現-~target ~LET コレの $currentTarget 属性~値 ◎ Let currentTarget be this’s currentTarget attribute value.
- %~composed経路 に %現-~target を`付加する$ ◎ Append currentTarget to composedPath.
- %現-~target~index ~LET 0 ◎ Let currentTargetIndex be 0.
- %現-~targetの~hidden下位tree~level ~LET 0 ◎ Let currentTargetHiddenSubtreeLevel be 0.
- %~index ~LET %経路 の`~size$ − 1 ◎ Let index be path’s size − 1.
-
~WHILE[ %~index ~GTE 0 ]: ◎ While index is greater than or equal to 0:
- ~IF[ %経路[ %~index ] の`閉な~treeの根?$evP ~EQ ~T ] ⇒ %現-~targetの~hidden下位tree~level ~INCBY 1 ◎ If path[index]'s root-of-closed-tree is true, then increase currentTargetHiddenSubtreeLevel by 1.
- ~IF[ %経路[ %~index ] の`呼出n~target$evP ~EQ %現-~target ] ⇒# %現-~target~index ~SET %~index; ~BREAK ◎ If path[index]'s invocation target is currentTarget, then set currentTargetIndex to index and break.
- ~IF[ %経路[ %~index ] の`~slotは閉な~tree内?$evP ~EQ ~T ] ⇒ %現-~targetの~hidden下位tree~level ~DECBY 1 ◎ If path[index]'s slot-in-closed-tree is true, then decrease currentTargetHiddenSubtreeLevel by 1.
- %~index ~DECBY 1 ◎ Decrease index by 1.
- %現-~hidden~level ~LET %現-~targetの~hidden下位tree~level ◎ ↓
- %最大-~hidden~level ~LET %現-~targetの~hidden下位tree~level ◎ Let currentHiddenLevel and maxHiddenLevel be currentTargetHiddenSubtreeLevel.
- %~index ~SET %現-~target~index ~MINUS 1 ◎ Set index to currentTargetIndex − 1.
-
~WHILE[ %~index ~GTE 0 ]: ◎ While index is greater than or equal to 0:
- ~IF[ %経路[ %~index ] の`閉な~treeの根?$evP ~EQ ~T ] ⇒ %現-~hidden~level ~INCBY 1 ◎ If path[index]'s root-of-closed-tree is true, then increase currentHiddenLevel by 1.
- ~IF[ %現-~hidden~level ~LTE %最大-~hidden~level ] ⇒ %~composed経路 に %経路[ %~index ] の`呼出n~target$evPを`前付加する$ ◎ If currentHiddenLevel is less than or equal to maxHiddenLevel, then prepend path[index]'s invocation target to composedPath.
-
~IF[ %経路[ %~index ] の`~slotは閉な~tree内?$evP ~EQ ~T ]: ◎ If path[index]'s slot-in-closed-tree is true, then:
- %現-~hidden~level ~DECBY 1 ◎ Decrease currentHiddenLevel by 1.
- ~IF[ %最大-~hidden~level ~GTE %現-~hidden~level ] ⇒ %最大-~hidden~level ~SET %現-~hidden~level ◎ If currentHiddenLevel is less than maxHiddenLevel, then set maxHiddenLevel to currentHiddenLevel.
- %~index ~DECBY 1 ◎ Decrease index by 1.
- %現-~hidden~level ~SET %現-~targetの~hidden下位tree~level ◎ ↓
- %最大-~hidden~level ~SET %現-~targetの~hidden下位tree~level ◎ Set currentHiddenLevel and maxHiddenLevel to currentTargetHiddenSubtreeLevel.
- %~index ~SET %現-~target~index ~PLUS 1 ◎ Set index to currentTargetIndex + 1.
-
~WHILE[ %~index ~LT %経路 の`~size$ ]: ◎ While index is less than path’s size:
- ~IF[ %経路[ %~index ] の`~slotは閉な~tree内?$evP ~EQ ~T ] ⇒ %現-~hidden~level ~INCBY 1 ◎ If path[index]'s slot-in-closed-tree is true, then increase currentHiddenLevel by 1.
- ~IF[ %現-~hidden~level ~LTE %最大-~hidden~level ] ⇒ %~composed経路 に %経路[ %~index ] の`呼出n~target$evPを`付加する$ ◎ If currentHiddenLevel is less than or equal to maxHiddenLevel, then append path[index]'s invocation target to composedPath.
-
~IF[ %経路[ %~index ] の`閉な~treeの根?$evP ~EQ ~T ]: ◎ If path[index]'s root-of-closed-tree is true, then:
- %現-~hidden~level ~DECBY 1 ◎ Decrease currentHiddenLevel by 1.
- ~IF[ %最大-~hidden~level ~GTE %現-~hidden~level ] ⇒ %最大-~hidden~level ~SET %現-~hidden~level ◎ If currentHiddenLevel is less than maxHiddenLevel, then set maxHiddenLevel to currentHiddenLevel.
- %~index ~INCBY 1 ◎ Increase index by 1.
- ~RET %~composed経路 ◎ Return composedPath.
@eventPhase 取得子~手続きは、初期化-時の値を返す — それは、次のいずれかをとるモノトスル(括弧内は数-値): ◎ The eventPhase attribute must return the value it was initialized to, which must be one of the following:
- @NONE (0)
- まだ`配送-$されていない`~event$はこの相に属する。 ◎ Events not currently dispatched are in this phase.
- @CAPTURING_PHASE (1)
- `~event$が`~tree$に`関与して$いる~objに向けて`配送-$されるとき、~eventがその`~target$に到達するまでは,この相に属する。 ◎ When an event is dispatched to an object that participates in a tree it will be in this phase before it reaches its target.
- @AT_TARGET (2)
- `~event$が`配送-$されるとき、~eventの`~target$上では,この相に属する。 ◎ When an event is dispatched it will be in this phase on its target.
- @BUBBLING_PHASE (3)
- `~event$が`~tree$に`関与して$いる~objに向けて`配送-$されるとき、~eventがその`~target$に到達した後は,この相に属する。 ◎ When an event is dispatched to an object that participates in a tree it will be in this phase after it reaches its target.
`~event$の作成-時には、この属性は $NONE に初期化するモノトスル。 ◎ Initially the attribute must be initialized to NONE.
各`~event$には、次に挙げる~flagが結付けられる — いずれも真偽値をとり,初期~時は ~F をとるとする ⇒# `伝播停止@f, `伝播即停止@f, `取消d@f, `受動~listener内@f, `~composed@f, `初期化-済み@f, `配送-@f ◎ Each event has the following associated flags that are all initially unset: • stop propagation flag • stop immediate propagation flag • canceled flag • in passive listener flag • composed flag • initialized flag • dispatch flag
`取消d~flagを設定する@ ときは、所与の ( `~event$ %~event ) に対し,次を走らすモノトスル ⇒ ~IF[ %~event の $cancelable 属性~値 ~EQ ~T ]~AND[ %~event の`受動~listener内$f ~EQ ~F ] ⇒ %~event の`取消d$f ~SET ~T ◎ To set the canceled flag, given an event event, if event’s cancelable attribute value is true and event’s in passive listener flag is unset, then set event’s canceled flag, and do nothing otherwise.
@preventDefault() ~method~手続きは ⇒ `取消d~flagを設定する$( コレ ) ◎ The preventDefault() method, when invoked, must set the canceled flag with this.
注記: $preventDefault() を呼出しても効果がない局面もある。 ~UAには、~debugを援助するため,精確な~~原因を開発者~consoleに~logすることが奨励される。 ◎ There are scenarios where invoking preventDefault() has no effect. User agents are encouraged to log the precise cause in a developer console, to aid debugging.
@isTrusted 取得子~手続きは、初期化-時の値を返す。 ◎ The isTrusted attribute must return the value it was initialized to.\
`~event$の作成-時には、この属性は ~F に初期化するモノトスル。 ◎ When an event is created the attribute must be initialized to false.
注記: $isTrusted は、`~event$は( $EventTarget.dispatchEvent() を利用してではなく)~UAにより`配送-$されたかどうかを簡便に指示する。 唯一の旧来の例外は `click()$m であり,~UAに`~event$を[ $isTrusted 属性は ~F に初期化- ]した上で配送させる。 ◎ isTrusted is a convenience that indicates whether an event is dispatched by the user agent (as opposed to using dispatchEvent()). The sole legacy exception is click(), which causes the user agent to dispatch an event whose isTrusted attribute is initialized to false.
`~eventを初期化する@ ときは、所与の ( %event, %type, %bubbles, %cancelable ) に対し, %event の各種~propを次のように設定するモノトスル ⇒# `初期化-済み$f ~SET ~T, `伝播停止$f ~SET ~F, `伝播即停止$f ~SET ~F, `取消d$f ~SET ~F, $isTrusted 属性 ~SET ~F, `~target$ ~SET ~NULL, $type 属性 ~SET %type, $bubbles 属性 ~SET %bubbles, $cancelable 属性 ~SET %cancelable ◎ To initialize an event, with type, bubbles, and cancelable, run these steps: • Set event’s initialized flag. • Unset event’s stop propagation flag, stop immediate propagation flag, and canceled flag. • Set event’s isTrusted attribute to false. • Set event’s target to null. • Set event’s type attribute to type. • Set event’s bubbles attribute to bubbles. • Set event’s cancelable attribute to cancelable.
@initEvent(type, bubbles, cancelable) ~method~手続きは: ◎ The initEvent(type, bubbles, cancelable) method, when invoked, must run these steps:
- ~IF[ コレの`配送-$f ~EQ ~T ] ⇒ ~RET ◎ If this’s dispatch flag is set, then return.
- `~eventを初期化する$( コレ, %type, %bubbles, %cancelable ) ◎ Initialize this with type, bubbles, and cancelable.
注記: $initEvent() は、`~event$には構築子があるので冗長であり, $composed も設定できないが、旧来の内容~用に~supportされる必要がある。 ◎ initEvent() is redundant with event constructors and incapable of setting composed. It has to be supported for legacy content.
2.3. ^Window ~interfaceに対する旧来の拡張
!! partial interface $Window { [`Replaceable$] ~RA ($Event or $undefined) `event$m; // }; !各 $Window ~objには `現在の~event@ が結付けられる。 それは,[ $undefined / $Event ~obj ]であり、他が言明されない限り, $undefined とする。 ◎ Each Window object has an associated current event (undefined or an Event object). Unless stated otherwise it is undefined.
注記: ~web開発者には、代わりに~event~listenerに渡される $Event ~objに依拠することが強く奨励される — その方が、~codeは より~portableになるので。 この属性は、~workerや~worklet内では可用でなく, `~shadow~tree$内に配送される~event用には 不正確になる。 ◎ Web developers are strongly encouraged to instead rely on the Event object passed to event listeners, as that will result in more portable code. This attribute is not available in workers or worklets, and is inaccurate for events dispatched in shadow trees.
2.4. ^@CustomEvent ~interface
!! [`Exposed$=(Window,Worker)] interface @CustomEvent : $Event { `CustomEvent$mc($DOMString %type, optional $CustomEventInit %eventInitDict = {}); ~RA $any $detail; $undefined $initCustomEvent($DOMString %type, optional $boolean %bubbles = false, optional $boolean %cancelable = false, optional $any %detail = null); // }; dictionary @CustomEventInit : $EventInit { $any @CustomEventInit.detail = null; }; !~custom~dataを運ばせる用途に, $CustomEvent ~interfaceを利用する`~event$を利用できる。 ◎ Events using the CustomEvent interface can be used to carry custom data.
- %event = $CustomEvent(type [, eventInitDict])
- $Event の構築子と相似的に働く — %eventInitDict 引数により, $detail 属性も設定できることを除いて。 ◎ Works analogously to the constructor for Event except that the eventInitDict argument now allows for setting the detail attribute too.
- %event . $detail
- %event の作成-時に与えられた~custom~dataを返す。 概して,合成な~eventで利用される。 【!initCustomEvent is dead】 ◎ Returns any custom data event was created with. Typically used for synthetic events.
@initCustomEvent(type, bubbles, cancelable, detail) ~method~手続きは: ◎ The initCustomEvent(type, bubbles, cancelable, detail) method must, when invoked, run these steps:
- ~IF[ コレの`配送-$f ~EQ ~T ] ⇒ ~RET ◎ If this’s dispatch flag is set, then return.
- `~eventを初期化する$( コレ, %type, %bubbles, %cancelable ) ◎ Initialize this with type, bubbles, and cancelable.
- コレの $detail 属性 ~SET %detail ◎ Set this’s detail attribute to detail.
2.5. ~eventの構築-法
`適用-可能な仕様$は、すべてまたは一部の`~event$用に `~event構築-時の手続き@ を定義してもヨイ。 この~algoは、`~eventを内的に作成する$手続き内から, ( `~event$ ) を渡して呼出される。 ◎ Specifications may define event constructing steps for all or some events. The algorithm is passed an event as indicated in the inner event creation steps.
注記: この構成子は、 $Event 下位classが,その初期化-用の辞書~memberと~IDL属性とが一対一に対応していない,より複階的な構造を備えるときに利用できる。 ◎ This construct can be used by Event subclasses that have a more complex structure than a simple 1:1 mapping between their initializing dictionary members and IDL attributes.
`~event構築子@ — [ $Event ~interface, または それを継承する~interface ] %~interface の構築子 — この仕様においては @Event.Event(type, eventInitDict), @CustomEvent.CustomEvent(type, eventInitDict) — は、次の手続きを走らすモノトスル: ◎ When a constructor of the Event interface, or of an interface that inherits from the Event interface, is invoked, these steps must be run, given the arguments type and eventInitDict:
- %~event ~LET `~eventを内的に作成する$( %~interface, ~NULL, 現在時, %eventInitDict ) ◎ Let event be the result of running the inner event creation steps with this interface, null, now, and eventInitDict.
- %~event の $Event.type 属性 ~SET %type に初期化する ◎ Initialize event’s type attribute to type.
- ~RET %~event ◎ Return event.
`~eventを作成する@ ときは、所与の ⇒# %~event~interface ( $Event または それを継承する~interface ), %~realm ( `~Realm$, 省略時は ~NULL ) ◎終 に対し,次を走らす: ◎ To create an event using eventInterface, which must be either Event or an interface that inherits from it, and optionally given a Realm realm, run these steps: • If realm is not given, then set it to null.
-
%辞書 ~LET ~JS `undefined^jv 値を[ %~event~interface の構築子が引数に受容する`辞書$型( $EventInit またはそれを継承する辞書~型) ]に`変換-$した結果 ◎ Let dictionary be the result of converting the JavaScript value undefined to the dictionary type accepted by eventInterface’s constructor. (This dictionary type will either be EventInit or a dictionary that inherits from it.)
これは、当の辞書~型に必須な~memberが在る場合に働かない。 whatwg/dom#600 を見よ。 ◎ This does not work if members are required; see whatwg/dom#600.
-
%~event ~LET `~eventを内的に作成する$( 次に挙げる引数 ) ⇒# %~event~interface, %~realm, 当の~eventが通達している何かが生じた時刻†, %辞書 ◎ Let event be the result of running the inner event creation steps with eventInterface, realm, the time of the occurrence that the event is signaling, and dictionary.
†注記: 例えば macOS においては、入力~動作が生じた時刻は ^NSEvent ~objの ^timestamp ~propを介して可用になる。 ◎ In macOS the time of the occurrence for input actions is available via the timestamp property of NSEvent objects.
- %~event の $isTrusted 属性 ~SET ~T に初期化する ◎ Initialize event’s isTrusted attribute to true.
- ~RET %~event ◎ Return event.
注記: `~eventを作成する$手続きは、単純に`~eventを発火する$代わりに[ `~eventを作成する$, ~eventを`配送-$する ]手続きを別々に呼出す必要がある,他の仕様からの利用が~~意図されている。 これは、~eventの属性が既定の値に正しく初期化されることを確保する。 ◎ Create an event is meant to be used by other specifications which need to separately create and dispatch events, instead of simply firing them. It ensures the event’s attributes are initialized to the correct defaults.
`~eventを内的に作成する@ ときは、所与の ( %~interface, %~realm, %時刻, %辞書 ) に対し,次を走らす: ◎ The inner event creation steps, given an interface, realm, time, and dictionary, are as follows:
-
%~event ~LET %~interface を利用する, %~realm 内の,新たな~obj — ただし, %~realm ~EQ ~NULL の場合は Web IDL に定義される既定の挙動に従う ◎ Let event be the result of creating a new object using eventInterface. If realm is non-null, then use that Realm; otherwise, use the default behavior defined in Web IDL.
これを書いている時点では、まだ Web IDL はこの既定の挙動を定義していない。 heycam/webidl#135 を見よ。 ◎ As of the time of this writing Web IDL does not yet define any default behavior; see heycam/webidl#135.
- %~event の`初期化-済み$f ~SET ~T ◎ Set event’s initialized flag.
-
%~event の $Event.timeStamp 属性 ~SET [ `時刻起点$から %時刻 までの高分解能な時間差 ]を表現している $DOMHighResTimeStamp 値に初期化する ◎ Initialize event’s timeStamp attribute to a DOMHighResTimeStamp representing the high resolution time from the time origin to time.
既存の時計~分解能の推奨 に従って、~UAは, $Event.timeStamp 属性を 5 マイクロ秒までの分解能に抑えるよう設定するべきである。 `HR-TIME$r ◎ User agents should set a minimum resolution of event’s timeStamp attribute to 5 microseconds following the existing clock resolution recommendation. [HR-TIME]
- %辞書 内の ~EACH( %~member → %値 ) に対し ⇒ ~IF[ %~event には %~member を`識別子$とする属性はある ] ⇒ その属性 ~SET %値 に初期化する ◎ For each member → value in dictionary, if event has an attribute whose identifier is member, then initialize that attribute to value.
- `~event構築-時の手続き$に ( %~event ) を渡して走らす ◎ Run the event constructing steps with event.
- ~RET %~event ◎ Return event.
2.6. ~event~interfaceの定義-法
一般に、$Event を継承する新たな~interfaceを定義する際には,常に WHATWG または W3C WebApps WG ~communityからの~feedbackを仰ぐように願う。 ◎ In general, when defining a new interface that inherits from Event please always ask feedback from the WHATWG or the W3C WebApps WG community.
$CustomEvent ~interfaceはその出発点に利用できるものだが、 `init*Event()^c の類いの~methodは,構築子とかぶって冗長になるので導入しないように。 $Event ~interfaceを継承する~interfaceがその種の~methodを備えているのは、歴史的な理由に限られている。 ◎ The CustomEvent interface can be used as starting point. However, do not introduce any init*Event() methods as they are redundant with constructors. Interfaces that inherit from the Event interface that have such a method only have it for historical reasons.
2.7. ^@EventTarget ~interface
!! [`Exposed$=(Window,Worker,AudioWorklet)] interface @EventTarget { `EventTarget$mc(); $undefined $addEventListener($DOMString %type, $EventListener? %callback, optional ($AddEventListenerOptions or $boolean) %options = {}); $undefined $removeEventListener($DOMString %type, $EventListener? %callback, optional ($EventListenerOptions or $boolean) %options = {}); $boolean $dispatchEvent($Event %event); }; callback interface @EventListener { $undefined @EventListener.handleEvent($Event %event); }; dictionary @@EventListenerOptions { $boolean @capture = false; }; dictionary @@AddEventListenerOptions : $EventListenerOptions { $boolean @passive = false; $boolean @once = false; $AbortSignal @signal; }; !$@EventTarget ~objは、何かが生じたとき,`~event$を`配送-$できる~targetを表現する。 ◎ An EventTarget object represents a target to which an event can be dispatched when something has occurred.
( 各 $EventTarget ~objには、 `~event~listener~list@ が結付けられる — それは、 0 個~以上の`~event~listener$からなる`~list$であり,初期~時には空とする。 ◎ Each EventTarget object has an associated event listener list (a list of zero or more event listeners). It is initially the empty list.
`~event~listener@ を利用すれば、特定の`~event$を観測できる — それは、次に挙げるものからなる: ◎ An event listener can be used to observe a specific event and consists of:
- `type@evL ⇒ 文字列 ◎ type (a string)
- `callback@evL ⇒ ~NULL / $EventListener ~obj ◎ callback (null or an EventListener object)
- `capture@evL ⇒ 真偽値 — 初期~時は ~F とする ◎ capture (a boolean, initially false)
- `passive@evL ⇒ 真偽値 — 初期~時は ~F とする ◎ passive (a boolean, initially false)
- `once@evL ⇒ 真偽値 — 初期~時は ~F とする ◎ once (a boolean, initially false)
- `signal@evL ⇒ ~NULL / $AbortSignal ~obj ◎ signal (null or an AbortSignal object)
- `removed@evL ⇒ 内部処理用の真偽値 — 初期~時は ~F とする。 ◎ removed (a boolean for bookkeeping purposes, initially false)
注記: `callback$evL は $EventListener ~objであるが、`~event~listener$は 上に示したように より広い概念である。 ◎ Although callback is an EventListener object, an event listener is a broader concept as can be seen above.
各 $EventTarget ~objには、その `親~targetを取得する@ ~algoも結付けられる。 それは、所与の`~event$に対し,[ $EventTarget ~obj, または ~NULL ]を返す。 他から指定されない限り, ~NULL を返すとする。 ◎ Each EventTarget object also has an associated get the parent algorithm, which takes an event event, and returns an EventTarget object. Unless specified otherwise it returns null.
注記: [ `~node$ / `~shadow根$ / `文書$ ]は、`親~targetを取得する$~algoを上書きする。 ◎ Nodes, shadow roots, and documents override the get the parent algorithm.
【 この~algoは、~eventの`配送-$時にその伝播`経路$を構築するために利用される。 】【 指定される個々の~algoには、渡された~eventを利用しないものもある(その場合、~eventは省略して記述され得る)。 】
各 $EventTarget ~objには、 `作動化の挙動@ が結付けられ得る。 この~algoは、`配送-$する~algo内から, ( `~event$ ) を渡して呼出される。 ◎ Each EventTarget object can have an associated activation behavior algorithm. The activation behavior algorithm is passed an event, as indicated in the dispatch algorithm.
注記: これが存在するのは、~UAが ある種の $EventTarget ~objに対し,ある種の動作を遂行するためである — 例えば `area$e 要素は、合成な $MouseEvent `~event$に呼応して,その $Event.type 属性は `click^l にされる。 それを除去することは、~Web互換性のため できない。 それはまた、今や,何らかの作動化を定義するときに~~尊守されている仕方になっている。 `HTML$r ◎ This exists because user agents perform certain actions for certain EventTarget objects, e.g., the area element, in response to synthetic MouseEvent events whose type attribute is click. Web compatibility prevented it from being removed and it is now the enshrined way of defining an activation of something. [HTML]
加えて、`作動化の挙動$を有する各 $EventTarget ~objには、[ `旧来の作動化~前の挙動@, `旧来の作動化~取消~時の挙動@ ]を備えるものもある(片方のみ備えることはない)。 ◎ Each EventTarget object that has activation behavior, can additionally have both (not either) a legacy-pre-activation behavior algorithm and a legacy-canceled-activation behavior algorithm.
注記 これらの~algoは,[ Checkbox / Radio ]状態にある `input$e 要素のみに存在し、他では利用されない。 `HTML$r ◎ These algorithms only exist for checkbox and radio input elements and are not to be used for anything else. [HTML]
- %target = $EventTarget()
- 開発者が`~event$を`配送-$して~listenするために利用できる,新たな $EventTarget ~objを作成する。 ◎ Creates a new EventTarget object, which can be used by developers to dispatch and listen for events.
- %target . $addEventListener(type, callback [, options])
- %target の`~event~listener~list$に[ $Event.type 属性~値が %type である`~event$用の`~event~listener$ ]を付加する。 %callback 引数が,`~event$が`配送-$されたときに呼出される `callback$evL として設定される。 ◎ Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
- %options 引数は、~listenerに特有な~optionを設定する。 互換性のため、これは真偽値もとり得る — その場合、この~methodは,正確に[ %options の $EventListenerOptions.capture に その値が指定された ]かのように挙動する。 ◎ The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options’s capture.
- %options の $EventListenerOptions.capture が[ ~T / [ ~F または無い ]]ならば、 `callback$evL は,`~event$の $eventPhase 属性~値が[ $Event.BUBBLING_PHASE / $Event.CAPTURING_PHASE ]の間は呼出されないようになる。 いずれにせよ、`~event$の $Event.eventPhase 属性~値が $Event.AT_TARGET のときは, `callback$evL は呼出される。 ◎ When set to true, options’s capture prevents callback from being invoked when the event’s eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event’s eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event’s eventPhase attribute value is AT_TARGET.
- %options の $AddEventListenerOptions.passive が ~T に設定されている場合、 `callback$evL は $Event.preventDefault() を呼出しても`~event$を取消さないことを指示する。 これは、 ~event~listenerの観測-法 に述べる処理能の最適化を可能化するために利用される ◎ When set to true, options’s passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
- %options の $AddEventListenerOptions.once が ~T に設定されている場合、~callbackが呼出されるのは一度限りであり,その後には`~event~listener$は除去されることを指示する。 ◎ When set to true, options’s once indicates that the callback will only be invoked once after which the event listener will be removed.
- %options の $AddEventListenerOptions.signal に $AbortSignal が渡された場合、その通達が中止されたとき~event~listenerは除去されることになる。 ◎ If an AbortSignal is passed for options’s signal, then the event listener will be removed when signal is aborted.
- `~event~listener$は、重複しない — すなわち, `type$evL, `callback$evL, `capture$evL のいずれかが異なる — 場合に限り, %target の`~event~listener~list$に付加される。 ◎ The event listener is appended to target’s event listener list and is not appended if it has the same type, callback, and capture.
- %target . $removeEventListener(type, callback [, options])
- 引数と同じ[ `type$evL, `callback$evL, `capture$evL ]を持つ`~event~listener$を, %target の`~event~listener~list$から除去する。 ◎ Removes the event listener in target’s event listener list with the same type, callback, and options.
- %target . $dispatchEvent(event)
- 合成な~event %event を %target に向けて`配送-$する。 [ %event の $cancelable 属性~値が ~F であるか, または %event の $preventDefault() ~methodが呼出されていないとき ]は~T,他の場合は~F を返す。 ◎ Dispatches a synthetic event event to target and returns true if either event’s cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
%options を `平坦~化@ するときは、次を走らす: ◎ To flatten options, run these steps:
- ~RET %options の型に応じて ⇒# $boolean ならば %options / `辞書$ならば %options[ "$EventListenerOptions.capture" ] ◎ If options is a boolean, then return options. ◎ Return options["capture"].
%options を `もっと平坦~化@ するときは、次を走らす: ◎ To flatten more options, run these steps:
- ( %capture, %passive, %once, %signal ) ~LET ( %options を`平坦~化$した結果, ~F, ~F, ε ) ◎ Let capture be the result of flattening options. ◎ Let once and passive be false. ◎ Let signal be null.
- ~IF[ %options は`辞書$である ] ⇒# %passive ~SET %options[ "$AddEventListenerOptions.passive" ]; %once ~SET %options[ "$AddEventListenerOptions.once" ]; %signal ~SET %options[ "$AddEventListenerOptions.signal" ] ◎ If options is a dictionary, then: • Set passive to options["passive"] and once to options["once"]. • If options["signal"] exists, then set signal to options["signal"].
- ~IF[ %signal ~EQ ε ] ⇒ %signal ~SET ~NULL ◎ ↑
- ~RET ( %capture, %passive, %once, %signal ) ◎ Return capture, passive, once, and signal.
@EventTarget() 構築子~手続きは、何もしない。 ◎ The EventTarget() constructor, when invoked, must return a new EventTarget.
注記: 他所に言明される既定により、返される $EventTarget の`親~targetを取得する$~algoは,~NULL を返すことになり、[ `作動化の挙動$, `旧来の作動化~前の挙動$, `旧来の作動化~取消~時の挙動$ ]は無い。 ◎ Because of the defaults stated elsewhere, the returned EventTarget's get the parent algorithm will return null, and it will have no activation behavior, legacy-pre-activation behavior, or legacy-canceled-activation behavior.
注記: 将来には、`親~targetを取得する$~custom~algoも許容され得る。 作者は、それが自身の~programに有用になるなら知らせてほしい。 今の所は、作者が作成したどの $EventTarget も,~tree構造には関与しない。 ◎ In the future we could allow custom get the parent algorithms. Let us know if this would be useful for your programs. For now, all author-created EventTargets do not participate in a tree structure.
`~event~listenerを追加する@ ときは、所与の ( $EventTarget ~obj %~target, `~event~listener$ %~listener ) に対し,次を走らす: ◎ To add an event listener, given an EventTarget object eventTarget and an event listener listener, run these steps:
-
~IF[ %~target は $ServiceWorkerGlobalScope ~objである ]~AND[ %~target の`~sw$SWGの`~script資源$の`過去評価済み~flag$ ~EQ ~T ]~AND[ %~listener の `type$evL は ある`~sw~event$の $type 属性~値に合致する† ]`SERVICE-WORKERS$r ⇒ `~consoleに警告を報告する$( “期待される結果を与えないであろう” ) ◎ If eventTarget is a ServiceWorkerGlobalScope object, its service worker’s script resource’s has ever been evaluated flag is set, and listener’s type matches the type attribute value of any of the service worker events, then report a warning to the console that this might not give the expected results. [SERVICE-WORKERS]
【† そのような~eventの~instanceが在ることも要求しているかのように解釈できる条件だが、単に,~sw~eventの ^type 属性~値がとり得る値の集合に入ることを意味するのかも? (しかしながら、`~event~listenerを除去する$ときのように,明示的な用語 “`取扱う~event型の集合$” を利用していないので、実際にその解釈が意図されているのかもしれない。) 】
- %通達 ~LET %~listener の`signal$evL ◎ ↓
- ~IF[ %通達 ~NEQ ~NULL ]~AND[ %通達 の`中止-済み~flag$aB ~EQ ~T ] ⇒ ~RET ◎ If signal is not null and its aborted flag is set, then return.
- ~IF[ %~listener の`callback$evL ~EQ ~NULL ] ⇒ ~RET ◎ If listener’s callback is null, then return.
- ~IF[ 次を満たす`~event~listener$ %L は無い ]… ⇒ [ %L ~IN %~target の`~event~listener~list$ ]~AND[ %L の ( `type$evL, `callback$evL, `capture$evL ) ~EQ %~listener の ( `type$evL, `callback$evL, `capture$evL ) ] ◎終 …ならば ⇒ %~target の`~event~listener~list$に %~listener を`付加する$ ◎ If eventTarget’s event listener list does not contain an event listener whose type is listener’s type, callback is listener’s callback, and capture is listener’s capture, then append listener to eventTarget’s event listener list.
- ~IF[ %通達 ~NEQ ~NULL ] ⇒ `通達に~algoを追加する$( %通達, 次を走らす中止-手続き ) ⇒ `~event~listenerを除去する$( %~target, %~listener ) ◎ If listener’s signal is not null, then add the following abort steps to it: • Remove an event listener with eventTarget and listener.
注記: [ `~event~listenerを追加する$ ]の概念は、[ `~event~handler$ `HTML$r が同じ `code path^en【!*】 を利用する ]ことを確保するためにある。 ◎ The add an event listener concept exists to ensure event handlers use the same code path. [HTML]
@addEventListener(type, callback, options) ~method~手続きは: ◎ The addEventListener(type, callback, options) method, when invoked, must run these steps:
- ( %capture, %passive, %once, %signal ) ~LET %options を`もっと平坦~化$した結果 ◎ Let capture, passive, and once be the result of flattening more options.
- `~event~listenerを追加する$( コレ, 次のように設定された`~event~listener$ ) ⇒# `type$evL ~SET %type , `callback$evL ~SET %callback , `capture$evL ~SET %capture , `passive$evL ~SET %passive , `once$evL ~SET %once, `signal$evL ~SET %signal ◎ Add an event listener with this and an event listener whose type is type, callback is callback, capture is capture, passive is passive, once is once, and signal is signal.
`~event~listenerを除去する@ ときは、所与の ( $EventTarget ~obj %~target, `~event~listener$ %~listener ) に対し,次を走らす: ◎ To remove an event listener, given an EventTarget object eventTarget and an event listener listener, run these steps:
- ~IF[ %~target は $ServiceWorkerGlobalScope ~objである ]~AND[ %type 【 %~listener の `type$evL ?】 ~NIN %~target の`~sw$SWGが`取扱う~event型の集合$ ]`SERVICE-WORKERS$r ⇒ `~consoleに警告を報告する$( “期待される結果を与えないであろう” ) ◎ If eventTarget is a ServiceWorkerGlobalScope object and its service worker’s set of event types to handle contains type, then report a warning to the console that this might not give the expected results. [SERVICE-WORKERS]
- %~listener の `removed$evL ~SET ~T; ◎ Set listener’s removed to true and\
- %~target の`~event~listener~list$から %~listener を`除去する$ ◎ remove listener from eventTarget’s event listener list.
注記: ~HTMLは、~event~handlerを定義するために これを必要とする。 `HTML$r ◎ HTML needs this to define event handlers. [HTML]
`~event~listenerをすべて除去する@ ときは、所与の ( $EventTarget ~obj %~target ) に対し,次を走らす ⇒ %~target の`~event~listener~list$内の ~EACH( %~listener ) に対し ⇒ `~event~listenerを除去する$( %~target, %~listener ) ◎ To remove all event listeners, given an EventTarget object eventTarget, for each listener of eventTarget’s event listener list, remove an event listener with eventTarget and listener.
注記: ~HTMLは、 ^document.open() を定義するために これを必要とする。 `HTML$r ◎ HTML needs this to define document.open(). [HTML]
@removeEventListener(type, callback, options) ~method~手続きは: ◎ The removeEventListener(type, callback, options) method, when invoked, must run these steps:
- %capture ~LET %options を`平坦~化$した結果 ◎ Let capture be the result of flattening options.
- ~IF[ 次を満たす`~event~listener$ %~listener は在る ]… ⇒ [ %~listener ~IN コレの`~event~listener~list$ ]~AND[ %~listener の ( `type$evL, `callback$evL, `capture$evL ) ~EQ ( %type, %callback, %capture ) ] ◎終 …ならば ⇒ `~event~listenerを除去する$( コレ, %~listener ) ◎ If this’s event listener list contains an event listener whose type is type, callback is callback, and capture is capture, then remove an event listener with this and that event listener.
注記: ~event~listener~listが ( `type^evL, `callback^evL, `capture^evL ) が互いに等しい複数の~event~listenerを包含することはない。 それは、`~event~listenerを追加する$ときに防止される。 ◎ The event listener list will not contain multiple event listeners with equal type, callback, and capture, as add an event listener prevents that.
@dispatchEvent(event) ~method~手続きは: ◎ The dispatchEvent(event) method, when invoked, must run these steps:
- ~IF[ %event の`配送-$f ~EQ ~T ]~OR[ %event の`初期化-済み$f ~EQ ~F ] ⇒ ~THROW `InvalidStateError$E ◎ If event’s dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException.
- %event の $isTrusted 属性 ~SET ~F に初期化する ◎ Initialize event’s isTrusted attribute to false.
- ~RET コレに向けて %event を`配送-$した結果 ◎ Return the result of dispatching event to this.
2.8. ~event~listenerの観測-法
一般に、開発者は,`~event~listener$の有無が観測-可能になるものとは予期しない。 `~event~listener$の影響iは、その `callback$evL により決定される。 すなわち開発者は、何もしない`~event~listener$を追加しても,副作用が生じるとは予期しない。 ◎ In general, developers do not expect the presence of an event listener to be observable. The impact of an event listener is determined by its callback. That is, a developer adding a no-op event listener would not expect it to have any side effects.
あいにく,一部の~event~APIは、効率的に実装するためには,`~event~listener$を観測することが要求される設計になっている。 すなわち、何もしない~listenerであっても,~appの挙動における処理能に劇的に影響iし得る結果、~listenerの有無が観測-可能になっている。 例えば ~touch/~wheel ~eventの利用は、非同期~scrollingを阻むことがある。 一部の事例では、[ ~eventが $cancelable になるのは, $AddEventListenerOptions.passive でない~listenerが 1 個~以上あるときに限る ]ように指定することで,この問題を軽減できる。 例えば、 $AddEventListenerOptions.passive でない $TouchEvent ~listenerは,~scrollingを阻まなければならないが、どの~listenerも $AddEventListenerOptions.passive であれば,[ $TouchEvent を( $preventDefault() の~callは無視されるように)取消せなくすることで,~scrollingを`並列的$に開始できる ]ようになる。 ~eventを配送している~codeは、そのように $AddEventListenerOptions.passive でない~listenerが無いことを観測でき,それを利用して配送-中の~eventの $cancelable ~propを ~F にできる。 ◎ Unfortunately, some event APIs have been designed such that implementing them efficiently requires observing event listeners. This can make the presence of listeners observable in that even empty listeners can have a dramatic performance impact on the behavior of the application. For example, touch and wheel events which can be used to block asynchronous scrolling. In some cases this problem can be mitigated by specifying the event to be cancelable only when there is at least one non-passive listener. For example, non-passive TouchEvent listeners must block scrolling, but if all listeners are passive then scrolling can be allowed to start in parallel by making the TouchEvent uncancelable (so that calls to preventDefault() are ignored). So code dispatching an event is able to observe the absence of non-passive listeners, and use that to clear the cancelable property of the event being dispatched.
新たな~event~APIは、この~propを必要としないように定義されるのが理想的である(論を交わしたければ public-script-coord@w3.org を利用されたし)。 ◎ Ideally, any new event APIs are defined such that they do not need this property (use public-script-coord@w3.org for discussion).
2.9. ~eventの配送-法
%target に向けて,`~event$ %~event を `配送-@ するときは、次を走らす — この手続きには,[ %旧来の~targetを上書きする~flag ~IN { `~targetを上書きする^i, ε }(省略時は ε ) ]も与えられ得る: ◎ To dispatch an event to a target, with an optional legacy target override flag and an optional legacyOutputDidListenersThrowFlag, run these steps:
【 原文の~algoでは,[ Indexed Database API のみから利用される %legacyOutputDidListenersThrowFlag ]も — 参照渡しとして — 入力に渡され得るが、この訳では,[ 関連な~eventに`旧来の(~listenerは投出したか?)~flag$を結付けるよう定義する ]ことにより、この入力の受け渡しに関する記述を 簡素化している。 】
- %~event の`配送-$f ~SET ~T ◎ Set event’s dispatch flag.
-
%上書きする~target ~LET [ %旧来の~targetを上書きする~flag ~EQ ε ならば %target / ~ELSE_ %target に`結付けられている文書$ `HTML$r ] ◎ Let targetOverride be target, if legacy target override flag is not given, and target’s associated Document otherwise. [HTML]
注記: %旧来の~targetを上書きする~flag は、~HTMLからのみ, それも %target が $Window ~objである場合に限り,非 ε にされる。 ◎ legacy target override flag is only used by HTML and only when target is a Window object.
- %作動化~target ~LET ~NULL ◎ Let activationTarget be null.
- %関係d~target ~LET %~event の`関係d~target$を %target に向けて`~targetし直す$ ◎ Let relatedTarget be the result of retargeting event’s relatedTarget against target.
-
~IF[ %target ~NEQ %関係d~target ]~OR[ %target ~EQ %~event の`関係d~target$ ]: ◎ If target is not relatedTarget or target is event’s relatedTarget, then:
- %~touch~target~list ~LET 新たな`~list$ ◎ Let touchTargets be a new list.
- %~event の`~touch~target~list$内の ~EACH( %~touch~target ) に対し ⇒ %~touch~target~list に次の結果を`付加する$ ⇒ %~touch~target を %~target に向けて`~targetし直す$ ◎ For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against target to touchTargets.
- `~event経路に付加する$( %~event, %target, %上書きする~target, %関係d~target, %~touch~target~list, ~F ) ◎ Append to an event path with event, target, targetOverride, relatedTarget, touchTargets, and false.
- %作動化~eventか? ~LET[ %~event は次を満たすならば ~T / ~ELSE_ ~F ] ⇒ [ $MouseEvent ~objである ]~AND[ $type 属性 ~EQ `click^l ] ◎ Let isActivationEvent be true, if event is a MouseEvent object and event’s type attribute is "click", and false otherwise.
- ~IF[ %作動化~eventか? ~EQ ~T ]~AND[ %target は`作動化の挙動$を有する ] ⇒ %作動化~target ~SET %target ◎ If isActivationEvent is true and target has activation behavior, then set activationTarget to target.
- %~slottable ~LET[ 次が満たされるならば %~target / ~ELSE_ ~NULL ] ⇒ [ %~target は`~slottable$である ]~AND[ %~target の`割当先~slot$ ~NEQ ~NULL ] ◎ Let slottable be target, if target is a slottable and is assigned, and null otherwise.
- %~slotは閉な~tree内? ~LET ~F ◎ Let slot-in-closed-tree be false.
- %親 ~LET %target の`親~targetを取得する$( %~event ) ◎ Let parent be the result of invoking target’s get the parent with event.
-
~WHILE[ %親 ~NEQ ~NULL ]: ◎ While parent is non-null:
-
~IF[ %~slottable ~NEQ ~NULL ]: ◎ If slottable is non-null:
- ~Assert: %親 は`~slot$である ◎ Assert: parent is a slot.
- %~slottable ~SET ~NULL ◎ Set slottable to null.
- ~IF[ %親 の`根$は[ `~shadow根$である ]~AND[ `~mode$sR ~EQ `closed^l ]を満たす ] ⇒ %~slotは閉な~tree内? ~SET ~T ◎ If parent’s root is a shadow root whose mode is "closed", then set slot-in-closed-tree to true.
- ~IF[ %親 は`~slottable$である ]~AND[ %親 の`割当先~slot$ ~NEQ ~NULL ] ⇒ %~slottable ~SET %親 ◎ If parent is a slottable and is assigned, then set slottable to parent.
- %関係d~target ~LET %関係d~target を %親 に向けて`~targetし直す$ ◎ Let relatedTarget be the result of retargeting event’s relatedTarget against parent.
- %~touch~target~list ~LET 新たな`~list$ ◎ Let touchTargets be a new list.
- %~event の`~touch~target~list$内の ~EACH( %~touch~target ) に対し ⇒ %~touch~target~list に次の結果を`付加する$ ⇒ %~touch~target を %親 に向けて`~targetし直す$ ◎ For each touchTarget of event’s touch target list, append the result of retargeting touchTarget against parent to touchTargets.
-
~IF[ %親 は $Window ~objである ]~OR[[ %親 は`~node$である ]~AND[ %target の`根$ は %親 の`~shadowも含む広義先祖$である ]]: ◎ If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then:
-
~IF[ %作動化~eventか? ~EQ ~T ]~AND[ %~event の $bubbles 属性 ~EQ ~T ]~AND[ %作動化~target ~EQ ~NULL ]~AND[ %親 は`作動化の挙動$を有する ] ⇒ %作動化~target ~SET %親 ◎ If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent.
- `~event経路に付加する$( %~event, %親, ~NULL, %関係d~target, %~touch~target~list, %~slotは閉な~tree内? ) ◎ Append to an event path with event, parent, null, relatedTarget, touchTargets, and slot-in-closed-tree.
-
- ~ELIF[ %親 ~EQ %関係d~target ] ⇒ %親 ~SET ~NULL ◎ Otherwise, if parent is relatedTarget, then set parent to null.
-
~ELSE: ◎ Otherwise,\
- %target ~SET %親 ◎ set target to parent and then:
- ~IF[ %作動化~eventか? ~EQ ~T ]~AND[ %作動化~target ~EQ ~NULL ]~AND[ %target は`作動化の挙動$を有する ] ⇒ %作動化~target ~SET %target ◎ If isActivationEvent is true, activationTarget is null, and target has activation behavior, then set activationTarget to target.
- `~event経路に付加する$( %~event, %親, %target, %関係d~target, %~touch~target~list, %~slotは閉な~tree内? ) ◎ Append to an event path with event, parent, target, relatedTarget, touchTargets, and slot-in-closed-tree.
- ~IF[ %親 ~NEQ ~NULL ] ⇒ %親 ~SET %親 の`親~targetを取得する$( %~event ) ◎ If parent is non-null, then set parent to the result of invoking parent’s get the parent with event.
- %~slotは閉な~tree内? ~SET ~F ◎ Set slot-in-closed-tree to false.
-
- %~targetを消去する構造体 ~LET %~event の`経路$内の構造体のうち,[ `~shadow調整-済み~target$evP ~NEQ ~NULL ]を満たすもののうち,最後のもの ◎ Let clearTargetsStruct be the last struct in event’s path whose shadow-adjusted target is non-null.
- %~targetたちを消去する ~LET 次を満たす`~node$ %~node は[ 在るならば ~T / 無いならば ~F ] ⇒ [ その`根$は`~shadow根$である ]~AND[ 次に挙げるいずれかである ] ⇒# %~targetを消去する構造体 の`~shadow調整-済み~target$evP, %~targetを消去する構造体 の`関係d~target$evP, %~targetを消去する構造体 の`~touch~target~list$evP 内に在る ◎ Let clearTargets be true if clearTargetsStruct’s shadow-adjusted target, clearTargetsStruct’s relatedTarget, or an EventTarget object in clearTargetsStruct’s touch target list is a node and its root is a shadow root, and false otherwise.
- ~IF[ %作動化~target ~NEQ ~NULL ]~AND[ %作動化~target は `旧来の作動化~前の挙動$を備えている ] ⇒ その挙動を走らす ◎ If activationTarget is non-null and activationTarget has legacy-pre-activation behavior, then run activationTarget’s legacy-pre-activation behavior.
-
%~event の`経路$内の ~EACH( %構造体 ) に対し,逆順に: ◎ For each struct in event’s path, in reverse order:
- %~event の $eventPhase 属性 ~SET [ %構造体 の`~shadow調整-済み~target$evP ~NEQ ~NULL ならば $AT_TARGET / ~ELSE_ $CAPTURING_PHASE ] ◎ If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET. ◎ Otherwise, set event’s eventPhase attribute to CAPTURING_PHASE.
- `~listenerを呼出す$( %構造体, %~event, `capturing^l ) ◎ Invoke with struct, event, "capturing", and legacyOutputDidListenersThrowFlag if given.
-
%~event の`経路$内の ~EACH( %構造体 ) に対し: ◎ For each struct in event’s path:
- ~IF[ %構造体 の`~shadow調整-済み~target$evP ~NEQ ~NULL ] ⇒ %~event の $eventPhase 属性 ~SET $AT_TARGET ◎ If struct’s shadow-adjusted target is non-null, then set event’s eventPhase attribute to AT_TARGET.
-
~ELSE: ◎ Otherwise:
- ~IF[ %~event の $bubbles 属性 ~EQ ~F ] ⇒ ~CONTINUE ◎ If event’s bubbles attribute is false, then continue.
- %~event の $eventPhase 属性 ~SET $BUBBLING_PHASE ◎ Set event’s eventPhase attribute to BUBBLING_PHASE.
- `~listenerを呼出す$( %構造体, %~event, `bubbling^l ) ◎ Invoke with struct, event, "bubbling", and legacyOutputDidListenersThrowFlag if given.
- %~event の $eventPhase 属性 ~SET $NONE ◎ Set event’s eventPhase attribute to NONE.
- %~event の $currentTarget 属性 ~SET ~NULL ◎ Set event’s currentTarget attribute to null.
- %~event の`経路$ ~SET 空~list ◎ Set event’s path to the empty list.
- %~event の ⇒# `配送-$f ~SET ~F, `伝播停止$f ~SET ~F, `伝播即停止$f ~SET ~F ◎ Unset event’s dispatch flag, stop propagation flag, and stop immediate propagation flag.
-
~IF[ %~targetたちを消去する ~EQ ~T ] ⇒ %~event の ⇒# `~target$ ~SET ~NULL `関係d~target$ ~SET ~NULL `~touch~target~list$ ~SET 空~list ◎ If clearTargets, then: • Set event’s target to null. • Set event’s relatedTarget to null. • Set event’s touch target list to the empty list.
-
~IF[ %作動化~target ~NEQ ~NULL ]: ◎ If activationTarget is non-null, then:
- ~IF[ %~event の`取消d$f ~EQ ~F ] ⇒ %~event を渡して, %作動化~target の`作動化の挙動$を走らす ◎ If event’s canceled flag is unset, then run activationTarget’s activation behavior with event.
- ~ELIF[ %作動化~target は `旧来の作動化~取消~時の挙動$を備えている ] ⇒ その挙動を走らす ◎ Otherwise, if activationTarget has legacy-canceled-activation behavior, then run activationTarget’s legacy-canceled-activation behavior.
- ~RET %~event の`取消d$f ◎ Return false if event’s canceled flag is set, and true otherwise.
`~event経路に付加する@ ときは、所与の ( %~event, %呼出n~target, %~shadow調整-済み~target, %関係d~target, %~touch~target~list, %~slotは閉な~tree内? ) に対し,次を走らす: ◎ To append to an event path, given an event, invocationTarget, shadowAdjustedTarget, relatedTarget, touchTargets, and a slot-in-closed-tree, run these steps:
- %呼出n~targetは~shadow~tree内? ~LET [ %呼出n~target は次を満たすならば ~T / ~ELSE_ ~F ] ⇒ [ `~node$である ]~AND[ その`根$は`~shadow根$である ] ◎ Let invocationTargetInShadowTree be false. ◎ If invocationTarget is a node and its root is a shadow root, then set invocationTargetInShadowTree to true.
- %閉な~treeの根? ~LET [ %呼出n~target は次を満たすならば ~T / ~ELSE_ ~F ] ⇒ [ `~shadow根$である ]~AND[ `~mode$sR ~EQ `closed^l ] ◎ Let root-of-closed-tree be false. ◎ If invocationTarget is a shadow root whose mode is "closed", then set root-of-closed-tree to true.
- %~event の`経路$に次のように設定された新たな`構造体$を`付加する$ ⇒# `呼出n~target$evP ~SET %呼出n~target, `呼出n~targetは~shadow~tree内?$evP ~SET %呼出n~targetは~shadow~tree内? `~shadow調整-済み~target$evP ~SET %~shadow調整-済み~target, `関係d~target$evP ~SET %関係d~target, `閉な~treeの根?$evP ~SET %閉な~treeの根?, `~touch~target~list$evP ~SET %~touch~target~list `~slotは閉な~tree内?$evP ~SET %~slotは閉な~tree内? ◎ Append a new struct to event’s path whose invocation target is invocationTarget, invocation-target-in-shadow-tree is invocationTargetInShadowTree, shadow-adjusted target is shadowAdjustedTarget, relatedTarget is relatedTarget, touch target list is touchTargets, root-of-closed-tree is root-of-closed-tree, and slot-in-closed-tree is slot-in-closed-tree.
`~listenerを呼出す@ ときは、所与の ( %構造体, %~event, %相 ) に対し,次を走らす: ◎ To invoke, given a struct, event, phase, and an optional legacyOutputDidListenersThrowFlag, run these steps:
- %~event の`~target$ ~SET [ %~event の`経路$内の[ %構造体 または %構造体 に先行する構造体 ]のうち,[ `~shadow調整-済み~target$evP ~NEQ ~NULL ]を満たすもののうち,最後の構造体 ]の`~shadow調整-済み~target$evP ◎ Set event’s target to the shadow-adjusted target of the last struct in event’s path, that is either struct or preceding struct, whose shadow-adjusted target is non-null.
- %~event の`関係d~target$ ~SET %構造体 の `関係d~target$evP ◎ Set event’s relatedTarget to struct’s relatedTarget.
- %~event の`~touch~target~list$ ~SET %構造体 の`~touch~target~list$evP ◎ Set event’s touch target list to struct’s touch target list.
- ~IF[ %~event の`伝播停止$f ~EQ ~T ] ⇒ ~RET ◎ If event’s stop propagation flag is set, then return.
- %~event の $currentTarget 属性 ~SET %構造体 の`呼出n~target$evPに初期化する ◎ Initialize event’s currentTarget attribute to struct’s invocation target.
-
%~listener~list ~LET %構造体 の`呼出n~target$evPの`~event~listener~list$を`~cloneする$ ◎ Let listeners be a clone of event’s currentTarget attribute value’s event listener list.
注記: これは、この時点以降に追加された~event~listenerは,走らせないようにする。 除去については、 `removed$evL ~fieldに因り,依然として効果を及ぼすことに注意。 ◎ This avoids event listeners added after this point from being run. Note that removal still has an effect due to the removed field.
- %呼出n~targetは~shadow~tree内? ~LET %構造体 の`呼出n~targetは~shadow~tree内?$evP ◎ Let invocationTargetInShadowTree be struct’s invocation-target-in-shadow-tree.
- %見出された? ~LET `~listenerを内的に呼出す$( %~event, %~listener~list, %相, %呼出n~targetは~shadow~tree内? ) ◎ Let found be the result of running inner invoke with event, listeners, phase, invocationTargetInShadowTree, and legacyOutputDidListenersThrowFlag if given.
-
~IF[ %見出された? ~EQ ~F ]~AND[ %~event の $isTrusted 属性 ~EQ ~T ]~AND[ %~event の $type 属性~値は[ 下の表の 1 列目に挙げるいずれかの文字列 ]に `~ASCII大小無視$で合致する ]…: ◎ If found is false and event’s isTrusted attribute is true, then: ◎ Let originalEventType be event’s type attribute value. ◎ If event’s type attribute value is a match for any of the strings in the first column in the following table, set event’s type attribute value to the string in the second column on the same row as the matching string, and return otherwise.
~event型◎ Event type 旧来の~event型◎ Legacy event type `animationend^l `webkitAnimationEnd^l `animationiteration^l `webkitAnimationIteration^l `animationstart^l `webkitAnimationStart^l `transitionend^l `webkitTransitionEnd^l …ならば:
- %元の~event型 ~LET %~event の $type 属性~値 ◎ ↑
- %~event の $type 属性 ~SET 合致した行の 2 列目に与える文字列 ◎ ↑
- `~listenerを内的に呼出す$( %~event, %~listener~list, %相, %呼出n~targetは~shadow~tree内? ) ◎ Inner invoke with event, listeners, phase, invocationTargetInShadowTree, and legacyOutputDidListenersThrowFlag if given.
- %~event の $type 属性 ~SET %元の~event型 ◎ Set event’s type attribute value to originalEventType.
`~listenerを内的に呼出す@ ときは、所与の ( %~event, %~listener~list, %相, %呼出n~targetは~shadow~tree内? ) に対し,次を走らす: ◎ To inner invoke, given an event, listeners, phase, invocationTargetInShadowTree, and an optional legacyOutputDidListenersThrowFlag, run these steps:
- %見出された? ~LET ~F ◎ Let found be false.
-
%~listener~list 内の ~EACH( `~event~listener$ %~listener ) に対し: ◎ For each listener in listeners, whose removed is false:
- ~IF[ %~listener の `removed$evL ~EQ ~T ] ⇒ ~CONTINUE ◎ ↑
- ~IF[ %~listener の `type$evL ~NEQ %~event の $type 属性~値 ] ⇒ ~CONTINUE ◎ If event’s type attribute value is not listener’s type, then continue.
- %見出された? ~SET ~T ◎ Set found to true.
- ~IF[ %相 ~EQ `capturing^l ]~AND[ %~listener の `capture$evL ~EQ ~F ] ⇒ ~CONTINUE ◎ If phase is "capturing" and listener’s capture is false, then continue.
- ~IF[ %相 ~EQ `bubbling^l ]~AND[ %~listener の `capture$evL ~EQ ~T ] ⇒ ~CONTINUE ◎ If phase is "bubbling" and listener’s capture is true, then continue.
- ~IF[ %~listener の `once$evL ~EQ ~T ] ⇒ %~event の $currentTarget 属性~値の`~event~listener~list$から %~listener を`除去する$ ◎ If listener’s once is true, then remove listener from event’s currentTarget attribute value’s event listener list.
- %大域 ~LET %~listener の `callback$evL が`属する~Realm$の`大域~obj$rM ◎ Let global be listener callback’s associated Realm’s global object.
- %現在の~event ~LET $undefined ◎ Let currentEvent be undefined.
-
~IF[ %大域 は $Window ~objである ]: ◎ If global is a Window object, then:
- %現在の~event ~SET %大域 の`現在の~event$ ◎ Set currentEvent to global’s current event.
- ~IF[ %呼出n~targetは~shadow~tree内? ~EQ ~F ] ⇒ %大域 の`現在の~event$ ~SET %~event ◎ If invocationTargetInShadowTree is false, then set global’s current event to event.
- ~IF[ %~listener の `passive$evL ~EQ ~T ] ⇒ %~event の`受動~listener内$f ~SET ~T ◎ If listener’s passive is true, then set event’s in passive listener flag.
-
次を与える下で,`利用元~objの演算を~callする$ ⇒# %~listener の `callback$evL, `handleEvent^l, « %~event », %~event の$currentTarget 属性~値 ◎ Call a user object’s operation with listener’s callback, "handleEvent", « event », and event’s currentTarget attribute value.\
~callした結果,例外が投出されたときは、~catchして: ◎ If this throws an exception, then:
- `その例外を報告する$ ◎ Report the exception.
-
~IF[ %~event には`旧来の(~listenerは投出したか?)~flag$が結付けられている ] ⇒ %~event の`旧来の(~listenerは投出したか?)~flag$ ~SET ~T ◎ Set legacyOutputDidListenersThrowFlag if given.
注記: Indexed Database API `INDEXEDDB$r のみが、この~flagを利用する。 ◎ The legacyOutputDidListenersThrowFlag is only used by Indexed Database API. [INDEXEDDB]
- %~event の`受動~listener内$f ~SET ~F ◎ Unset event’s in passive listener flag.
- ~IF[ %大域 は $Window ~objである ] ⇒ %大域 の`現在の~event$ ~SET %現在の~event ◎ If global is a Window object, then set global’s current event to currentEvent.
- ~IF[ %~event の`伝播即停止$f ~EQ ~T ] ⇒ ~RET %見出された? ◎ If event’s stop immediate propagation flag is set, then return found.
- ~RET %見出された? ◎ Return found.
2.10. ~eventの発火-法
%~target に向けて,名前 %e の `~eventを発火する@ ときは、以下の手続きを走らす — この手続きには、次の~~入力も与えられ得る:
- %旧来の~targetを上書きする~flag ~IN { `~targetを上書きする^i, ε }(省略時は ε )
- %~event構築子 (省略時は $@Event のそれ)
- %記述 — [ ~eventの各種~IDL属性を どう初期化するか ]についての記述(省略時は何もしない)
- %~event ~LET `~eventを作成する$( %~event構築子, %~target に`関連な~Realm$ ) ◎ Let event be the result of creating an event given eventConstructor, in the relevant Realm of target.
- %~event の $type 属性 ~SET %e に初期化する ◎ Initialize event’s type attribute to e.
-
%~event の各種~IDL属性を %記述 に従って初期化する ◎ Initialize any other IDL attributes of event as described in the invocation of this algorithm.
注記: ここでは[ $isTrusted 属性 ~SET ~F ]にすることも許容される。 ◎ This also allows for the isTrusted attribute to be set to false.
【 この手続きを利用している他の仕様には、~IDL属性の他にも,~eventの各種~flag( `~composed$f など)を初期化する記述を含んでいるものもある。 】
- ~RET %~event を%~target に向けて`配送-$する( %旧来の~targetを上書きする~flag ) ◎ Return the result of dispatching event at target, with legacy target override flag set if set.
注記: ~DOMの文脈における “`~eventを発火する$” とは、`~event$を[ 作成-して, 初期化して, `配送-$する ]ことの略語であり,この処理-を容易に書けるようにするためにある。 ◎ Fire in the context of DOM is short for creating, initializing, and dispatching an event. Fire an event makes that process easier to write down.
`~event$の[ $bubbles や $cancelable ]属性も初期化する必要もある場合、次のように書くこともできる ⇒ %~target に向けて,名前 `submit^et の`~eventを発火する$ — 次のように初期化して ⇒ ^cancelable 属性 ~SET ~T ◎ If the event needs its bubbles or cancelable attribute initialized, one could write "fire an event named submit at target with its cancelable attribute initialized to true".
あるいは,~custom構築子も必要なときは、次のように書く等々 ⇒ %~target に向けて,名前 `click^et の`~eventを発火する$ — $MouseEvent を利用し,次のように初期化して ⇒ `detail$m 属性 ~SET 1 ◎ Or, when a custom constructor is needed, "fire an event named click at target using MouseEvent with its detail attribute initialized to 1".
ときには、返り値が重要になることもある: ◎ Occasionally the return value is important:
- %何かする ~LET %~target に向けて,名前 `like^et の`~eventを発火する$ ◎ Let doAction be the result of firing an event named like at target.
- ~IF[ %何かする ~EQ ~T ] ⇒ … ◎ If doAction is true, then …
2.11. 動作 vs. ~~発生
`~event$は、動作( `action^en )ではなく,何かが生じたこと( `occurrence^en )をしるす(徴す/ `signify^en する)ものである。 言葉を代えれば、~algoからの通知を表現し,その~algoの進路に(例えば $preventDefault() を呼出すことを通して)波及させるために利用できるものである。 `~event$は、何らかの~algoを走らすような[ 動作, あるいは動作を起動するもの ]として利用されてはナラナイ。 そのような用途にあるものではない。 ◎ An event signifies an occurrence, not an action. Phrased differently, it represents a notification from an algorithm and can be used to influence the future course of that algorithm (e.g., through invoking preventDefault()). Events must not be used as actions or initiators that cause some algorithm to start running. That is not what they are for.
注記: ここで特定的に~~強調している~~理由は、以前の~DOMでは,`~event$に “既定~動作” の概念が結付けられていて,人を誤った考えに~~導いていたからである。 `~event$は、動作を表現したり生じさせるものではなく,進行中の何かに波及させるために限り利用できるものである。 ◎ This is called out here specifically because previous iterations of the DOM had a concept of "default actions" associated with events that gave folks all the wrong ideas. Events do not represent or cause actions, they can only be used to influence an ongoing one.
3. 進行中の活動の中止-法
~promiseには,中止するための組込みの仕組みがないが、それを利用している多くの~APIは,中止-の意味論を要求している。 $AbortController には、その要件を~supportすることが~~意図されている。 それが供する $abort() ~methodは、 $AbortController に対応している $AbortSignal ~objの状態を切り替える。 中止-法を~supportしたいと望む~APIは、この~objを受容して, その状態を利用することにより,どう続行するか決定できる。 ◎ Though promises do not have a built-in aborting mechanism, many APIs using them require abort semantics. AbortController is meant to support these requirements by providing an abort() method that toggles the state of a corresponding AbortSignal object. The API which wishes to support aborting can accept an AbortSignal object, and use its state to determine how to proceed.
$AbortController に依拠する~APIは、新たな `AbortError$E 例外で未決着な~promiseを却下して, $abort() に応答することが奨励される。 ◎ APIs that rely upon AbortController are encouraged to respond to abort() by rejecting any unsettled promise with a new "AbortError" DOMException.
~method `doAmazingness({ ... })^c は、何か “すごいこと” を行うとする。 この~methodは、 $AbortSignal ~objを受容して,次のように中止-法を~supportできる: ◎ A hypothetical doAmazingness({ ... }) method could accept an AbortSignal object in order to support aborting as follows:
const %controller = new AbortController(); const %signal = %controller.signal; startSpinner(); doAmazingness({ ..., %signal }) .then(%result => ...) .catch(%err => { if (%err.name == 'AbortError') return; showUserErrorMessage(); }) .then(() => stopSpinner()); // … %controller.abort();
^doAmazingness は、次のように実装することもできる: ◎ doAmazingness could be implemented as follows:
function doAmazingness({%signal}) { if (%signal.aborted) { return Promise.reject(new DOMException('Aborted', 'AbortError')); } return new Promise((%resolve, %reject) => { /* “すごいこと” を行い始め、終わったら %resolve(%result) を~callする。 また、 %signal も注視する。 ◎ Begin doing amazingness, and call resolve(result) when done. But also, watch for signals: */ %signal.addEventListener('abort', () => { /* “すごいこと” を行うのを停止してから: ◎ Stop doing amazingness, and: */ %reject(new DOMException('Aborted', 'AbortError')); }); }); }
より精細な制御を要する~APIは、必要に応じて $AbortController, $AbortSignal 両~objを拡張することもできる。 ◎ APIs that require more granular control could extend both AbortController and AbortSignal objects according to their needs.
3.1. ^@AbortController ~interface
!! `Exposed$=(Window,Worker)] interface @AbortController { `AbortController$mc(); [`SameObject$] ~RA $AbortSignal $signal; $undefined $abort(); }; !- %controller = $AbortController()
- 新たな %controller を,その $signal を[ 新たな $AbortSignal ~obj ]に設定した上で返す。 ◎ Returns a new controller whose signal is set to a newly created AbortSignal object.
- %controller . $signal
- この~objに結付けられている $AbortSignal ~objを返す。 ◎ Returns the AbortSignal object associated with this object.
- %controller . $abort()
- この~methodを呼出すと、この~objの $AbortSignal の`中止-済み~flag$aBを ~T にした上で、結付けられている活動が中止されることになるよう,観測器たちにも通達することになる。 ◎ Invoking this method will set this object’s AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
各 $AbortController ~objには、 `通達@aB ( $AbortSignal ~obj)が結付けられる。 ◎ An AbortController object has an associated signal (an AbortSignal object).
@AbortController() 構築子~手続きは ⇒ コレの`通達$aB ~SET 新たな $AbortSignal ~obj ◎ The new AbortController() constructor steps are: • Let signal be a new AbortSignal object. • Set this’s signal to signal.
3.2. ^@AbortSignal ~interface
!! [`Exposed$=(Window,Worker)] interface @AbortSignal : $EventTarget { ~RA $boolean $aborted; attribute $EventHandler $onabort; }; !- %signal . $aborted
- この $AbortSignal の $AbortController が,中止するよう通達されて[ いれば ~T / いなければ ~F ]を返す。 ◎ Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
各 $AbortSignal ~objには、次に挙げるものが結付けられる:
- `中止-済み~flag@aB
- 真偽値。 他が指定されない限り, ~F をとるとする。 ◎ An AbortSignal object has an associated aborted flag. It is unset unless specified otherwise.
- `中止する~algoたち@aB
- 何個かの~algoからなる`有順序~集合$。 他が指定されない限り,空とする。 これらの~algoは、[ `中止-済み~flag$aB ~SET ~T ]にされたとき,実行されることになる。 ◎ An AbortSignal object has associated abort algorithms, which is a set of algorithms which are to be executed when its aborted flag is set. Unless specified otherwise, its value is the empty set.
- 【 集合なので,同じ~algoは重ねて現れ得ないことになるが、 “同じ” がどう定義されるかは, “`通達に~algoを追加する$” を利用する他の仕様を見ないとはっきりしない。 】
`通達に~algoを追加する@ ときは、所与の ( $AbortSignal ~obj %通達, ~algo %~algo ) に対し,次を走らす: ◎ To add an algorithm algorithm to an AbortSignal object signal, run these steps:
- ~IF[ %通達 の`中止-済み~flag$aB ~EQ ~T ] ⇒ ~RET ◎ If signal’s aborted flag is set, then return.
- %通達 の`中止する~algoたち$aBに %~algo を`付加する$set ◎ Append algorithm to signal’s abort algorithms.
`通達から~algoを除去する@ ときは、所与の ( $AbortSignal ~obj %通達, ~algo %A ) に対し ⇒ %通達 の`中止する~algoたち$aBから %A を`除去する$ ◎ To remove an algorithm algorithm from an AbortSignal signal, remove algorithm from signal’s abort algorithms.
注記: `中止する~algoたち$aBは、 $abort() に対し適度な仕方で反応するような,複階的な要件を伴う~APIを可能化する。 例えば,所与の~APIの`中止-済み~flag$aBは、~swなどの別~thread環境へ伝播される必要があるかもしれない。 ◎ The abort algorithms enable APIs with complex requirements to react in a reasonable way to abort(). For example, a given API’s aborted flag might need to be propagated to a cross-thread environment, such as a service worker.
@onabort は、 `onabort@c `~event~handler$用の`~event~handler~IDL属性$である — その`~event~handler~event型$は `abort@et とする。 ◎ The onabort attribute is an event handler IDL attribute for the onabort event handler, whose event handler event type is abort.
注記: $AbortSignal ~objに対する変化は,対応している $AbortController ~objの望みを表現するが、 $AbortSignal ~objを観測している~APIは,それを無視することも選べる — 一例として、演算がすでに完了していた場合など。 ◎ Changes to an AbortSignal object represent the wishes of the corresponding AbortController object, but an API observing the AbortSignal object can chose to ignore them. For instance, if the operation has already completed.
`中止-を通達する@ ときは、所与の ( $AbortSignal ~obj %通達 ) に対し,次を走らす: ◎ To signal abort, given a AbortSignal object signal, run these steps:
- ~IF[ %通達 の`中止-済み~flag$aB ~EQ ~T ] ⇒ ~RET ◎ If signal’s aborted flag is set, then return.
- %通達 の`中止-済み~flag$aB ~SET ~T ◎ Set signal’s aborted flag.
- %通達 の`中止する~algoたち$aB内の ~EACH( %~algo ) に対し ⇒ %~algo を走らす ◎ For each algorithm in signal’s abort algorithms: run algorithm.
- %通達 の`中止する~algoたち$aBを`空にする$ ◎ Empty signal’s abort algorithms.
- %通達 に向けて名前 `abort$et の`~eventを発火する$ ◎ Fire an event named abort at signal.
`通達に追従させる@ ときは、所与の ( $AbortSignal %追従する通達, $AbortSignal %親~通達 ) に対し,次の手続きを走らす: ◎ A followingSignal (an AbortSignal) is made to follow a parentSignal (an AbortSignal) by running these steps:
- ~IF[ %追従する通達 の`中止-済み~flag$aB ~EQ ~T ] ⇒ ~RET ◎ If followingSignal’s aborted flag is set, then return.
- ~IF[ %親~通達 の`中止-済み~flag$aB ~EQ ~T ] ⇒# `中止-を通達する$( %追従する通達 ); ~RET ◎ If parentSignal’s aborted flag is set, then signal abort on followingSignal.
-
`通達に~algoを追加する$( %親~通達, 次に与える中止-手続き ): ◎ Otherwise, add the following abort steps to parentSignal:
- `中止-を通達する$( %追従する通達 ) ◎ Signal abort on followingSignal.
3.3. ~APIにおける ^AbortController, ^AbortSignal ~objの利用-法
中止できる演算を表現する~promiseを利用している~web~platform~APIは、次を固守するモノトスル: ◎ Any web platform API using promises to represent operations that can be aborted must adhere to the following:
- ^signal `辞書~member$を通して, $AbortSignal ~objを受容すること。 ◎ Accept AbortSignal objects through a signal dictionary member.
- 演算が中止されたときは、 `AbortError$E 例外で~promiseを却下することにより,それを~~伝えること。 ◎ Convey that the operation got aborted by rejecting the promise with an "AbortError" DOMException.
-
$AbortSignal の`中止-済み~flag$aBに応じて:
- すでに ~T の場合: 即時に却下すること。 ◎ Reject immediately if the AbortSignal's aborted flag is already set, otherwise:
- 他の場合: $AbortSignal ~objの変化を観測するときは、`中止する~algoたち$aBによる仕組みを,他の観測器と衝突し得ない方式で利用すること。 ◎ Use the abort algorithms mechanism to observe changes to the AbortSignal object and do so in a manner that does not lead to clashes with other observers.
~promiseを返す ある~method ^doAmazingness(options) 用の手続きは、次のように記すこともできる: ◎ The steps for a promise-returning method doAmazingness(options) could be as follows:
- %すごいこと ~LET ^doAmazingness が行う何か ◎ ↓
- %~promise ~LET `新たな~promise$ ◎ Let p be a new promise.
- %通達 ~LET %options[ "^signal" ] ◎ ↓
-
~IF[ %通達 ~NEQ ε ]: ◎ If options’ signal member is present, then:
-
~IF[ %通達 の`中止-済み~flag$aB ~EQ ~T ]:
- `AbortError$E 例外で %~promise を`却下する$
- ~RET %~promise
-
`通達に~algoを追加する$( %通達, 次に与える中止-手続き ): ◎ Add the following abort steps to options’ signal:
- %すごいこと を停止する ◎ Stop doing amazing things.
- `AbortError$E 例外で %~promise を`却下する$ ◎ Reject p with an "AbortError" DOMException.
-
-
この段は、`並列的$に走らす: ◎ Run these steps in parallel:
- %すごい結果 ~LET %すごいこと をした結果 ◎ Let amazingResult be the result of doing some amazing things.
- %すごい結果 で %p を`解決する$ ◎ Resolve p with amazingResult.
- ~RET %p ◎ Return p.
~promiseを利用していない~APIであっても、アリな限り,上述を固守するべきである。 ◎ APIs not using promises should still adhere to the above as much as possible.
4. ~node
4.1. ~DOM序論
~DOM( “The DOM( Document Object Model )” )は元々,文書(特に,~HTML文書や~XML文書)に~accessして操作するための~APIを~~意味していたが、この仕様における語 “文書” は、短い静的な文書から 多彩な~multimediaを伴う長い小論や報告書,更には本格的な対話的~appまでに渡る、任意の~markupに基づく資源を指すものとして利用される。 ◎ In its original sense, "The DOM" is an API for accessing and manipulating documents (in particular, HTML and XML documents). In this specification, the term "document" is used for any markup-based resource, ranging from short static documents to long essays or reports with rich multimedia, as well as to fully-fledged interactive applications.
そのような各~文書は、`~node~tree$として表現される。 `~tree$を成す`~node$のうち一部は 他の`~node$を`子$に持ち,他のものは葉(末端)~nodeになる。 ◎ Each such document is represented as a node tree. Some of the nodes in a tree can have children, while others are always leaves.
次の~HTML文書を例に~~説明する: ◎ To illustrate, consider this HTML document:
<!DOCTYPE html> <html class=e> <head><title>Aliens?</title></head> <body>Why yes.</body> </html>
これは次のように表現される: ◎ It is represented as follows:
- `文書$
- `~doctype$: `DOCTYPE html^c
- `要素$: `html^e `class^c=`e^l
- `要素$: `head^e
- `要素$: `title^e
- $Text: Aliens?
- `要素$: `title^e
- $Text: ⏎␣
- `要素$: `body^e
- $Text: Why yes.⏎
- `要素$: `head^e
`~HTML構文解析器$の~~仕組みから,すべての`~ASCII空白$が $Text `~node$にされてはいないが、一般~概念は明らかである。 ~~入力の~markupから,`~node$たちが成す`~tree$が出来上がる。 【!You /can/ explain that! harharhar】 ◎ Note that, due to the magic that is HTML parsing, not all ASCII whitespace were turned into Text nodes, but the general concept is clear. Markup goes in, a tree of nodes comes out.
注記: さらに探求してみたければ、最高によくできている Live DOM Viewer を利用するといい。 ◎ The most excellent Live DOM Viewer can be used to explore this matter in more detail.
4.2. ~node~tree
次に挙げる~interfaceを実装する~objが、`~tree$に`関与-$する ⇒# $Document, $DocumentType, $DocumentFragment, $Element, $Text, $ProcessingInstruction, $Comment
これらは総称して、単に `~node@ と呼ばれる。 また、これらが成す`~tree$は, `~node~tree@ と称される。
◎ Document, DocumentType, DocumentFragment, Element, Text, ProcessingInstruction, and Comment objects (simply called nodes) participate in a tree, simply named the node tree.`~node~tree$には、`~node$の型とそれに許容される`子$との関係性で表出される,次の拘束が課される: ◎ A node tree is constrained as follows, expressed as a relationship between the type of node and its allowed children:
- $Document
-
`~tree順序$において,次からなる: ◎ In tree order:
- それぞれが $ProcessingInstruction または $Comment である, 0 個以上の~node ◎ Zero or more nodes each of which is ProcessingInstruction or Comment.
- 0 個または 1 個の $DocumentType ~node ◎ Optionally one DocumentType node.
- 0 個または 1 個の $Element ~node ◎ Optionally one Element node.
- $DocumentFragment
- $Element
- それぞれが $Element, $ProcessingInstruction, $Comment, $Text のいずれかである, 0 個以上の~nodeからなる ◎ Zero or more nodes each of which is Element, Text, ProcessingInstruction, or Comment.
- $DocumentType
- $Text
- $ProcessingInstruction
- $Comment
- 子を持たない ◎ None.
`~node$ %node の `長さ@ とは、 %node に応じて,次で与えられる整数である: ◎ To determine the length of a node node, switch on node:
- $DocumentType
- 0 ◎ Zero.
- `文字~data~node$ ◎ Text ProcessingInstruction Comment
- その`~data$の`長さ$str ◎ Its data’s length.
- $Document
- $DocumentFragment
- $Element
- 【!他の~node】 その`子$の個数 ◎ Its number of children.
`~node$が `空@node であるとは、[ その`長さ$ ~EQ 0 ]を意味する。 【この訳では、この用語は利用しない — ほぼ利用されておらず,単に “長さ ~EQ 0” と記せば済むので。】 ◎ A node is considered empty if its length is zero.
4.2.1.文書~tree
`文書$を`根$とする`~node~tree$を `文書~tree@ という。 ◎ A document tree is a node tree whose root is a document.
`文書$ %文書 の `文書~要素@ とは、`要素$であって[ `親$ ~EQ %文書 ]を満たすものが[ 在れば それ / 無ければ ~NULL ]である。 ◎ The document element of a document is the element whose parent is that document, if it exists, and null otherwise.
注記: `~node~tree$の拘束から、そのような`要素$は唯一つに決まる。 【例えば`~HTML文書$ならば `html^e 要素。】 ◎ Per the node tree constraints, there can be only one such element.
`要素$は、その`根$が`文書$であるとき, `文書~tree内@ にあるという。 ◎ An element is in a document tree if its root is a document.
`文書~tree内$にある`要素$は、 `文書~内@ にあるともいう。 ◎ An element is in a document if it is in a document tree.\
注記: 用語 “`文書~内$” は、もはや利用されないものと想定されている。 この用語は、それを利用している標準が,まだ`~shadow~tree$を織り込むよう更新されていないことを指示する。 ◎ The term in a document is no longer supposed to be used. It indicates that the standard using it has not been updated to account for shadow trees.
4.2.2. ~shadow~tree
`~shadow根$を`根$とする`~node~tree$を `~shadow~tree@ という。 ◎ A shadow tree is a node tree whose root is a shadow root.
`~shadow根$は常に,その`~host$を通して別の`~node~tree$に添付けられる。 したがって,`~shadow~tree$が~~孤立することは決してない。 `~shadow根$の`~host$が`関与して$いる`~node~tree$は、 `~light~tree@ とも呼ばれる。 ◎ A shadow root is always attached to another node tree through its host. A shadow tree is therefore never alone. The node tree of a shadow root’s host is sometimes referred to as the light tree.
注記: `~shadow~tree$に対応する`~light~tree$は、それ自身`~shadow~tree$になり得る。 【~shadow( “日陰” )と違って,~light( “日なた” )の定義は相対的であり、ある~node~tree~~単独で “~lightである” とは言えない。】 ◎ A shadow tree’s corresponding light tree can be a shadow tree itself.
`要素$は、その`~shadowも含む根$が`文書$であるとき, `接続されて@ いるという。 ◎ An element is connected if its shadow-including root is a document.
4.2.2.1. ~slot
各`~shadow~tree$は、 0 個以上の, `~slot@ と呼ばれる`要素$を包含する。 ◎ A shadow tree contains zero or more elements that are slots.
注記: `~slot$は HTML の `slot$e 要素を通してのみ作成される。 ◎ A slot can only be created through HTML’s slot element.
各 `~slot$には、 `~slot名@ が結付けられる。 それは文字列であり、他が言明されない限り,空~文字列とする。 ◎ A slot has an associated name (a string). Unless stated otherwise it is the empty string.
`~slot$の`~slot名$の更新~時に利用する,`属性o変更-時の手続き$は、次で与えられる: ◎ Use these attribute change steps to update a slot’s name:
- ~IF[ %要素 は `~slot$でない ]~OR[ %局所~名 ~NEQ `name^l ]~OR[ %~ns ~NEQ ~NULL ] ⇒ ~RET ◎ If element is a slot, localName is name, and namespace is null, then:
-
~IF[ ( %値, %旧-値 ) は、次のいずれかを満たす ]…:
- %値 ~EQ %旧-値
- [ %値 ~IN { ~NULL, 空~文字列 } ]~AND[ %旧-値 ~IN { ~NULL, 空~文字列 } ]
…ならば ⇒ ~RET
◎ If value is oldValue, then return. ◎ If value is null and oldValue is the empty string, then return. ◎ If value is the empty string and oldValue is null, then return. - %要素 の`~slot名$ ~SET[ %値 ~IN { ~NULL, 空~文字列 } ならば 空~文字列 / ~ELSE_ %値 ] ◎ If value is null or the empty string, then set element’s name to the empty string. ◎ Otherwise, set element’s name to value.
- `~treeに~slottableたちを割当する$( %要素 の`根$ ) ◎ Run assign slottables for a tree with element’s root.
注記: `~shadow~tree$内の,[ `~slot名$ ~EQ 空~文字列 ]なる`~slot$のうち,`~tree順序$で最初のものは “既定の~slot” と称されることもある。 ◎ The first slot in a shadow tree, in tree order, whose name is the empty string, is sometimes known as the "default slot".
各 `~slot$には、 `割当された~nodeたち@ ( `assigned nodes^en )が結付けられる。 それは,`~slottable$の~listであり、他が言明されない限り,空とする。 ◎ A slot has an associated assigned nodes (a list of slottables). Unless stated otherwise it is empty.
4.2.2.2. ~slottable
[ $Element / $Text ]`~node$は、 `~slottable@ である。 【~slotは “はめ込み口”, ~slottableは “はめ込めるモノ” (名詞化された形容詞)。】 ◎ Element and Text nodes are slottables.
注記: `~slot$も、`~slottable$になり得る。 ◎ A slot can be a slottable.
各 `~slottable$には、 `名前@sB が結付けられる。 それは文字列であり、他が言明されない限り,空~文字列とする。 ◎ A slottable has an associated name (a string). Unless stated otherwise it is the empty string.
`~slottable$の`名前$sBの更新~時に利用する,`属性o変更-時の手続き$は、次で与えられる: ◎ Use these attribute change steps to update a slottable’s name:
- ~IF[ %局所~名 ~NEQ `slot^l ]~OR[ %~ns ~NEQ ~NULL ] ⇒ ~RET ◎ If localName is slot and namespace is null, then:
- %要素 の`名前$sB ~SET[ %値 ~IN { ~NULL, 空~文字列 } ならば 空~文字列 / ~ELSE_ %値 ] ◎ If value is null or the empty string, then set element’s name to the empty string. ◎ Otherwise, set element’s name to value.
- ~IF[ %要素 の`割当先~slot$ ~NEQ ~NULL ] ⇒ `~slotに~slottableたちを割当する$( その`~slot$ ) ◎ If element is assigned, then run assign slottables for element’s assigned slot.
- `~slottableを~slotに割当する$( %要素 ) ◎ Run assign a slot for element.
各 `~slottable$には、 `割当先~slot@ ( `assigned slot^en ) が結付けられる。 それは,[ ~NULL / `~slot$ ]であり、他が言明されない限り,~NULL とする。 【自身がどの`~slot$に割当されたかを指示する。】 ◎ A slottable has an associated assigned slot (null or a slot). Unless stated otherwise it is null.\
`割当先~slot$が ~NULL でない`~slottable$は、 `割当先がある@ ( `is assigned^en )という。 【この訳では、この用語は利用せず,直に “`割当先~slot$ ~NEQ ~NULL ” と記す。】 ◎ A slottable is assigned if its assigned slot is non-null.
4.2.2.3. ~slot / ~slottableの見出法
`~slottable用に~slotを見出す@ ときは、所与の ( `~slottable$ %~slottable, %開な~flag ~IN { `開な^i, ε }(省略時は ε ) ) に対し,次を走らす: ◎ To find a slot for a given slottable slottable and an optional open flag (unset unless stated otherwise), run these steps:
- ~IF[ %~slottable の`親$ ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If slottable’s parent is null, then return null.
- %~shadow ~LET %~slottable の`親$の`~shadow根$elm ◎ Let shadow be slottable’s parent’s shadow root.
- ~IF[ %~shadow ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If shadow is null, then return null.
- ~IF[ %開な~flag ~EQ `開な^i ]~AND[ %~shadow の`~mode$sR ~NEQ `open^l ] ⇒ ~RET ~NULL ◎ If the open flag is set and shadow’s mode is not "open", then return null.
- ~RET 次を満たす[ %~shadow の`子孫$ ]のうち,`~tree順序$で`最初のもの?$ ⇒ `~slot$であって,その`~slot名$ ~EQ %~slottable の`名前$sB ◎ Return the first slot in tree order in shadow’s descendants whose name is slottable’s name, if any, and null otherwise.
`~slot用に~slottableたちを見出す@ ときは、所与の ( `~slot$ %~slot ) に対し,次を走らす: ◎ To find slottables for a given slot slot, run these steps:
- %結果 ~LET 空~list ◎ Let result be an empty list.
- ~IF[ %~slot の`根$は`~shadow根$でない ] ⇒ ~RET %結果 ◎ If slot’s root is not a shadow root, then return result.
-
%~slot の`根$の`~host$の ~EACH( `~slottable$である`子$ %~slottable ) に対し,`~tree順序$で: ◎ Let host be slot’s root’s host. ◎ For each slottable child of host, slottable, in tree order:
- ~IF[ `~slottable用に~slotを見出す$( %~slottable ) ~EQ %~slot ] ⇒ %結果 に %~slottable を付加する ◎ Let foundSlot be the result of finding a slot given slottable. ◎ If foundSlot is slot, then append slottable to result.
- ~RET %結果 ◎ Return result.
`~slot用に平坦~化された~slottableたちを見出す@ ときは、所与の ( `~slot$ %~slot ) に対し,次を走らす: ◎ To find flattened slottables for a given slot slot, run these steps:
- %~slottable~list ~LET `~slot用に~slottableたちを見出す$( %~slot ) ◎ Let slottables be the result of finding slottables given slot.
- ~IF[ %~slottable~list は空である ] ⇒ %~slot の`子たち$を成す ~EACH( %子 ) に対し,`~tree順序$で ⇒ ~IF[ %子 は`~slottable$である ] ⇒ %~slottable~list に %子 を付加する ◎ If slottables is the empty list, then append each slottable child of slot, in tree order, to slottables.
-
%~slottable~list 内の ~EACH( %~node ) に対し: ◎ For each node in slottables:
-
~IF[ %~node は`~slot$である ]~AND[ %~node の`根$は`~shadow根$である ] ⇒ [ `~slot用に平坦~化された~slottableたちを見出す$( %~node ) ]内の ~EACH( `~slottable$ %~slottable ) に対し,順に ⇒ %結果 に %~slottable を付加する ◎ If node is a slot whose root is a shadow root, then: • Let temporaryResult be the result of finding flattened slottables given node. • Append each slottable in temporaryResult, in order, to result.
- ~ELSE ⇒ %結果 に %~node を付加する ◎ Otherwise, append node to result.
-
- ~RET %結果 ◎ Return result.
4.2.2.4. ~slottableたち/~slotの割当法
`~slotに~slottableたちを割当する@ ときは、所与の ( `~slot$ %~slot ) に対し,次を走らす: ◎ To assign slottables for a slot slot, run these steps:
- %~slottable~list ~LET `~slot用に~slottableたちを見出す$( %~slot ) ◎ Let slottables be the result of finding slottables for slot.
- ~IF[ %~slottable~list と %~slot に`割当された~nodeたち$とは、一致しない 【!*順序は関係ある?ない?】 ] ⇒ `~slotの変化を通達する$( %~slot ) ◎ If slottables and slot’s assigned nodes are not identical, then run signal a slot change for slot.
- %~slot に`割当された~nodeたち$ ~SET %~slottable~list ◎ Set slot’s assigned nodes to slottables.
- %~slottable~list 内の ~EACH( %~slottable ) に対し ⇒ %~slottable の`割当先~slot$ ~SET %~slot ◎ For each slottable in slottables, set slottable’s assigned slot to slot.
`~treeに~slottableたちを割当する@ ときは、所与の ( `~node$ %根 ) に対し,次を走らす ⇒ %根 の`広義子孫$である ~EACH( `~slot$ %~slot ) に対し,`~tree順序$で ⇒ `~slotに~slottableたちを割当する$( %~slot ) ◎ To assign slottables for a tree, given a node root, run assign slottables for each slot slot in root’s inclusive descendants, in tree order.
`~slottableを~slotに割当する@ ときは、所与の ( `~slottable$ %~slottable ) に対し、次を走らす: ◎ To assign a slot, given a slottable slottable, run these steps:
- %~slot ~LET `~slottable用に~slotを見出す$( %~slottable ) ◎ Let slot be the result of finding a slot with slottable.
- ~IF[ %~slot ~NEQ ~NULL ] ⇒ `~slotに~slottableたちを割当する$( %~slot ) ◎ If slot is non-null, then run assign slottables for slot.
4.2.2.5. ~slot変化の通達-法
各 `生成元が類似な~window~agent$ `HTML$r は、 `通達~slotたち@ を持つ。 それは,`~slot$たちが成す`有順序~集合$であり、初期~時は空とする。 ◎ Each similar-origin window agent has signal slots (a set of slots), which is initially empty. [HTML]
`~slotの変化を通達する@ ときは、所与の ( `~slot$ %~slot ) に対し,次を走らす: ◎ To signal a slot change, for a slot slot, run these steps:
- [ %~slot に`関連な~agent$の`通達~slotたち$ ]に %~slot を`付加する$set ◎ Append slot to slot’s relevant agent’s signal slots.
- `変異~観測器 小taskを~queueする$ ◎ Queue a mutation observer microtask.
4.2.3. 変異~algo
%node を %親 の中で %子 の前に `挿入できるかどうか検証する@ ときは、次を走らす: ◎ To ensure pre-insertion validity of a node into a parent before a child, run these steps:
- ~IF[ %親 は $Document, $DocumentFragment, $Element `~node$のいずれでもない ] ⇒ ~THROW `HierarchyRequestError$E ◎ If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
- ~IF[ %node は %親 の`~hostも含む広義先祖$である ] ⇒ ~THROW `HierarchyRequestError$E ◎ If node is a host-including inclusive ancestor of parent, then throw a "HierarchyRequestError" DOMException.
- ~IF[ %子 ~NEQ ~NULL ]~AND[ %子 の`親$ ~NEQ %親 ] ⇒ ~THROW `NotFoundError$E ◎ If child is non-null and its parent is not parent, then throw a "NotFoundError" DOMException.
-
~IF[ %node は $DocumentFragment, $DocumentType, $Element, $Text, $ProcessingInstruction, $Comment `~node$ のいずれでもない ] ⇒ ~THROW `HierarchyRequestError$E
【 すなわち “^Document ~nodeである”(何故そのように記されない?) 】
◎ If node is not a DocumentFragment, DocumentType, Element, Text, ProcessingInstruction, or Comment node, then throw a "HierarchyRequestError" DOMException. -
~IF[ 次のいずれかが満たされる ] ⇒ ~THROW `HierarchyRequestError$E :
- [ %node は $Text `~node$ である ]~AND[ %親 は`文書$である ]
- [ %node は`~doctype$である ]~AND[ %親 は`文書$でない ]
-
~IF[ %親 は`文書$である ]~AND[ %node に応じて,以下が満たされる ] ⇒ ~THROW `HierarchyRequestError$E ◎ If parent is a document, and any of the statements below, switched on node, are true, then throw a "HierarchyRequestError" DOMException.
- `文書片$ ◎ DocumentFragment node
-
次のいずれかが満たされる:
- %node の`子たち$内に在る`要素$の個数 ~GT 1 ◎ If node has more than one element child or\
- %node の`子たち$内に $Text `~node$が在る ◎ has a Text node child.
-
[ %node の`子たち$内に在る`要素$の個数 ~EQ 1 ]~AND[ 次のいずれかが満たされる ]:
【!"inclusively following"】- %親 の`子たち$内に`要素$が在る
- %子 は`~doctype$である
- [ %子 ~NEQ ~NULL ]~AND[ %子 に`後続-$する`~doctype$が在る ]
- `要素$
-
次のいずれかが満たされる:
◎ parent has an element child, child is a doctype, or child is non-null and a doctype is following child. - `~doctype$
-
次のいずれかが満たされる:
- %親 の`子たち$内に`~doctype$が在る
- [ %子 ~EQ ~NULL ]~AND[ %子 に`先行-$する`要素$が在る ]
- [ %子 ~EQ ~NULL ]~AND[ %親 の`子たち$内に`要素$が在る ]
%親 の中で `~nodeを子の前に前挿入する@ ときは、所与の ( %node, %子 ) に対し,次を走らす: ◎ To pre-insert a node into a parent before a child, run these steps:
- %node を %親 の中で %子 の前に`挿入できるかどうか検証する$ ◎ Ensure pre-insertion validity of node into parent before child.
- %基準~子 ~LET %子 ◎ Let referenceChild be child.
- ~IF[ %基準~子 ~EQ %node ] ⇒ %基準~子 ~SET %node の`次-同胞?$ ◎ If referenceChild is node, then set referenceChild to node’s next sibling.
- %親 の中で`~nodeを子の前に挿入する$( %node, %基準~子 ) ◎ Insert node into parent before referenceChild.
- ~RET %node 【!technically this is post-insert】 ◎ Return node.
`適用-可能な仕様$は、すべてまたは一部の`~node$用に `挿入-時の手続き@ を定義してもヨイ。 この~algoは、`~nodeを子の前に挿入する$~algo内から, ( `~node$ ) 【!*insertedNode】 を渡して呼出される。 ◎ Specifications may define insertion steps for all or some nodes. The algorithm is passed insertedNode, as indicated in the insert algorithm below.
`適用-可能な仕様$は、すべてまたは一部の`~node$用に `子たち変更-時の手続き@ を定義してもヨイ。 この~algoは、[ `~nodeを子の前に挿入する$/ `~nodeを除去する$/ `~dataを置換する$ ]~algo内から,引数なしで呼出される。 ◎ Specifications may define children changed steps for all or some nodes. The algorithm is passed no argument and is called from insert, remove, and replace data.
%親 の中で `~nodeを子の前に挿入する@ ときは、所与の ( %node, %子, %観測器は抑止する~flag ~IN { `観測器は抑止する^i, ε }(省略時は ε ) ) に対し,次を走らす: ◎ To insert a node into a parent before a child, with an optional suppress observers flag, run these steps:
- %nodes ~LET [ %node は`文書片$であるならば %node の`子たち$【を`~cloneする$】 / ~ELSE_ « %node » ] ◎ Let nodes be node’s children, if node is a DocumentFragment node; otherwise « node ».
- %count ~LET %nodes の`~size$ ◎ Let count be nodes’s size.
- ~IF[ %count ~EQ 0 ] ⇒ ~RET ◎ If count is 0, then return.
-
~IF[ %node は`文書片$である ]: ◎ If node is a DocumentFragment node, then:
- %nodes を成す ~EACH( %C ) に対し【!順序は関係なし】 ⇒ `~nodeを除去する$( %C, `観測器は抑止する^i ) ◎ Remove its children with the suppress observers flag set.
-
%node 用に`~tree変異~記録を~queueする$( « », %nodes, ~NULL, ~NULL ) ◎ Queue a tree mutation record for node with « », nodes, null, and null.
注記: この段では意図的に %観測器は抑止する~flag を~~無視する。 ◎ This step intentionally does not pay attention to the suppress observers flag.
-
~IF[ %子 ~NEQ ~NULL ] ⇒ ~EACH( `~live範囲o$ %範囲o ) に対し: ◎ If child is non-null, then:
- ~IF[ %範囲o の`始端~node$ ~EQ %親 ]~AND[ %範囲o の`始端~offset$ ~GT %子 の`~index$ ] ⇒ %範囲o の`始端~offset$ ~INCBY %count ◎ For each live range whose start node is parent and start offset is greater than child’s index, increase its start offset by count.
- ~IF[ %範囲o の`終端~node$ ~EQ %親 ]~AND[ %範囲o の`終端~offset$ ~GT %子 の`~index$† ] ⇒ %範囲o の`終端~offset$ ~INCBY %count ◎ For each live range whose end node is parent and end offset is greater than child’s index, increase its end offset by count.
【† 挿入される地点にちょうど一致する[ 範囲oの`境界点$ ]は、それが`終端$であっても,影響されないことになる — すなわち,挿入-後は 挿入された~nodeの直前を指す。 その結果,この~algoを利用している後述の`子を~nodeに置換する$ においては、除去される~nodeの直後または内部を指していた範囲oの境界点は,置換-後は 新たに挿入された~nodeの直前を指すようにされる(~node~treeの先頭/末尾から相対的な範囲oの始端/終端の位置変化のふるまいが,対称でない — 同様のことは,`~dataを置換する$~algoにも該当する)。 】
- %前-同胞 ~LET [ %子 ~NEQ ~NULL ならば %子 の`前-同胞?$ / ~ELSE_ %親 の`最後の子?$ ] ◎ Let previousSibling be child’s previous sibling or parent’s last child if child is null.
-
%nodes 内の ~EACH( %node ) に対し,`~tree順序$で: ◎ For each node in nodes, in tree order:
- %親 の`~node文書$に`~nodeを受入する$( %node ) ◎ Adopt node into parent’s node document.
- ~IF[ %子 ~EQ ~NULL ] ⇒ %親 の`子たち$に %node を`付加する$set ◎ If child is null, then append node to parent’s children.
- ~ELSE ⇒ %node を%親 の`子たち$の中で %子 の`~index$の前に`挿入する$ ◎ Otherwise, insert node into parent’s children before child’s index.
- ~IF[ %親 は`~shadow~host$である ]~AND[ %~node は`~slottable$である ] ⇒ `~slottableを~slotに割当する$( %~node ) ◎ If parent is a shadow host and node is a slottable, then assign a slot for node.
- ~IF[ %親 の`根$は`~shadow根$である ]~AND[ %親 は`~slot$である ]~AND[ %親 に`割当された~nodeたち$は 空~listである ] ⇒ `~slotの変化を通達する$( %親 ) ◎ If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent.
- `~treeに~slottableたちを割当する$( %~node の`根$ ) ◎ Run assign slottables for a tree with node’s root.
-
%~node の ~EACH( `~shadowも含む広義子孫$ %広義子孫 ) に対し,`~shadowも含む~tree順序$で: ◎ For each shadow-including inclusive descendant inclusiveDescendant of node, in shadow-including tree order:
- `挿入-時の手続き$に ( %広義子孫 ) を渡して走らす ◎ Run the insertion steps with inclusiveDescendant.
- ~IF[ %広義子孫 は`接続されて$いない ] ⇒ ~CONTINUE ◎ If inclusiveDescendant is connected, then:
- ~IF[ %広義子孫 は`~custom$である ] ⇒ `~custom要素~callback反応を~enqueueする$( %広義子孫, `connectedCallback^l, 空~list ) ◎ If inclusiveDescendant is custom, then enqueue a custom element callback reaction with inclusiveDescendant, callback name "connectedCallback", and an empty argument list.
-
~ELSE ⇒ `要素を昇格しようと試行する$( %広義子孫 ) ◎ Otherwise, try to upgrade inclusiveDescendant.
注記: %広義子孫 が成功裡に昇格された場合、その ^connectedCallback は,`要素を昇格する$~algoの間に自動的に~enqueueされる。 ◎ If this successfully upgrades inclusiveDescendant, its connectedCallback will be enqueued automatically during the upgrade an element algorithm.
- ~IF[ %観測器は抑止する~flag ~NEQ ε ] ⇒ %親 用に`~tree変異~記録を~queueする$( %nodes, « », %前-同胞, %子 ) ◎ If suppress observers flag is unset, then queue a tree mutation record for parent with nodes, « », previousSibling, and child.
- %親 用に`子たち変更-時の手続き$を走らす ◎ Run the children changed steps for parent.
%親 に `~nodeを付加する@ ときは、所与の ( %node ) に対し,次を走らす ⇒ %親 の中で`~nodeを子の前に前挿入する$( %node, ~NULL ) ◎ To append a node to a parent, pre-insert node into parent before null.
%親 の中で `子を~nodeに置換する@ ときは、所与の ( %子, %node ) に対し,次を走らす: ◎ To replace a child with node within a parent, run these steps:
- ~IF[ %子 の`親$ ~NEQ %親 ] ⇒ ~THROW `NotFoundError$E ◎ If child’s parent is not parent, then throw a "NotFoundError" DOMException.
-
- `文書片$ ◎ DocumentFragment node
-
次のいずれかが満たされる:
-
- %親 の`子たち$内に[ %子 でない`要素$ ]が在る
- %子 に`後続-$する`~doctype$が在る
-
- `要素$
-
次のいずれかが満たされる:
◎ parent has an element child that is not child or a doctype is following child. - `~doctype$
-
次のいずれかが満たされる:
- %親 の`子たち$内に[ %子 でない`~doctype$ ]が在る
- %子 に`先行-$する`要素$が在る
注記: この段は,`挿入できるかどうか検証する$ ~algoの似た段と異なる。 ◎ The above statements differ from the pre-insert algorithm.
- %基準~子 ~LET %子 の`次-同胞?$ ◎ Let referenceChild be child’s next sibling.
- %前-同胞 ~LET %子 の`前-同胞?$ ◎ Let previousSibling be child’s previous sibling.
- %除去-済み~nodeたち ~LET 空~集合 ◎ Let removedNodes be the empty set.
-
~IF[ %子 の`親$ ~NEQ ~NULL ]: ◎ If child’s parent is non-null, then:
- %除去-済み~nodeたち ~SET « %子 » ◎ Set removedNodes to « child ».
- `~nodeを除去する$( %子, `観測器は抑止する^i ) ◎ Remove child with the suppress observers flag set.
注記: この段の~~条件は[ %子 ~EQ %node ]の場合に限り,偽になる。 ◎ The above can only be false if child is node.
- %親 の中で`~nodeを子の前に挿入する$( %node, %基準~子, `観測器は抑止する^i ) ◎ Insert node into parent before referenceChild with the suppress observers flag set.
- %親 用に`~tree変異~記録を~queueする$( %nodes, %除去-済み~nodeたち, %前-同胞, %基準~子 ) ◎ Queue a tree mutation record for parent with nodes, removedNodes, previousSibling, and referenceChild.
- ~RET %子 ◎ Return child.
%親 の `全~内容を~nodeで置換する@ ときは、所与の ( %node ) に対し,次を走らす: ◎ To replace all with a node within a parent, run these steps:
- %除去-済み~nodeたち ~LET %親 の`子たち$ ◎ Let removedNodes be parent’s children.
- %追加-済み~nodeたち ~LET %node に応じて,次に与える集合 ⇒# ~NULL ならば « » / `文書片$であるならば %node の`子たち$【を`~cloneする$】 / ~ELSE_ « %node » ◎ Let addedNodes be the empty set. ◎ If node is a DocumentFragment node, then set addedNodes to node’s children. ◎ Otherwise, if node is non-null, set addedNodes to « node ».
- %親 の`子たち$を成す ~EACH( %子 ) に対し,`~tree順序$で ⇒ `~nodeを除去する$( %子, `観測器は抑止する^i ) ◎ Remove all parent’s children, in tree order, with the suppress observers flag set.
- ~IF[ %node ~NEQ ~NULL ] ⇒ %親 の中で`~nodeを子の前に挿入する$( %node, ~NULL, `観測器は抑止する^i ) ◎ If node is non-null, then insert node into parent before null with the suppress observers flag set.
- ~IF[ %追加-済み~nodeたち は`空$でない ]~OR[ %除去-済み~nodeたち は`空$でない ] ⇒ %親 用に`~tree変異~記録を~queueする$( %追加-済み~nodeたち, %除去-済み~nodeたち, ~NULL, ~NULL ) ◎ If either addedNodes or removedNodes is not empty, then queue a tree mutation record for parent with addedNodes, removedNodes, null, and null.
注記: この~algoは `~node~tree$に課される拘束を検査しない。 仕様の策定者は賢く利用すること。 ◎ This algorithm does not make any checks with regards to the node tree constraints. Specification authors need to use it wisely.
%親 から `子を前除去する@ ときは、所与の ( %子 ) に対し,次を走らす: ◎ To pre-remove a child from a parent, run these steps:
- `~nodeを除去する$( %子 ) ◎ Remove child.
- ~RET %子 【!technically this is post-remove】 ◎ Return child.
`適用-可能な仕様$は、すべてまたは一部の`~node$用に `除去-時の手続き@ を定義してもヨイ。 この~algoは、`~nodeを除去する$ ~algo内から, ( 除去された`~node$, 旧-`親$ (省略可能) ) を渡して呼出される。 ◎ Specifications may define removing steps for all or some nodes. The algorithm is passed removedNode, and optionally oldParent, as indicated in the remove algorithm below.
`~nodeを除去する@ ときは、所与の ( %~node, %観測器は抑止する~flag ~IN { `観測器は抑止する^i, ε }(省略時は ε ) ) に対し,次を走らす: ◎ To remove a node, with an optional suppress observers flag, run these steps:
- %親 ~LET %~node の`親$ ◎ Let parent be node’s parent
- ~Assert: %親 ~NEQ ~NULL ◎ Assert: parent is non-null.
- %~index ~LET %~node の`~index$ ◎ Let index be node’s index.
-
~EACH( `~live範囲o$ %範囲o ) に対し: ◎ ↓
- ~IF[ %範囲o の`始端~node$ は %~node の`広義子孫$である ] ⇒# %範囲o の`始端~node$ ~SET %親; %範囲o の`始端~offset$ ~SET %~index ◎ For each live range whose start node is an inclusive descendant of node, set its start to (parent, index).
- ~IF[ %範囲o の`終端~node$ は %~node の`広義子孫$である ] ⇒# %範囲o の`終端~node$ ~SET %親; %範囲o の`終端~offset$ ~SET %~index ◎ For each live range whose end node is an inclusive descendant of node, set its end to (parent, index).
- ~IF[ %範囲o の`始端~node$ ~EQ %親 ]~AND[ %範囲o の`始端~offset$ ~GT %~index ] ⇒ %範囲o の`始端~offset$ ~DECBY 1 ◎ For each live range whose start node is parent and start offset is greater than index, decrease its start offset by 1.
- ~IF[ %範囲o の`終端~node$ ~EQ %親 ]~AND[ %範囲o の`終端~offset$ ~GT %~index ] ⇒ %範囲o の`終端~offset$ ~DECBY 1 ◎ For each live range whose end node is parent and end offset is greater than index, decrease its end offset by 1.
- [ %反復子 の`根$tVの`~node文書$ ~EQ %~node `~node文書$ ]なる, ~EACH( $NodeIterator ~obj %反復子 ) に対し ⇒ `前除去-時の手続き$に ( %反復子, %~node ) を渡して走らす ◎ For each NodeIterator object iterator whose root’s node document is node’s node document, run the NodeIterator pre-removing steps given node and iterator.
- %前-同胞 ~LET %~node の`前-同胞?$ ◎ Let oldPreviousSibling be node’s previous sibling.
- %次-同胞 ~LET %~node の`次-同胞?$ ◎ Let oldNextSibling be node’s next sibling.
- %~node を %親 の`子たち$から`除去する$ ◎ Remove node from its parent’s children.
- ~IF[ %~node の`割当先~slot$ ~NEQ ~NULL ] ⇒ `~slotに~slottableたちを割当する$( その`~slot$ ) ◎ If node is assigned, then run assign slottables for node’s assigned slot.
-
~IF[[ %~node の`広義子孫$のうち,`~slot$であるもの ]は在る ]: ◎ If node has an inclusive descendant that is a slot, then:
- `~treeに~slottableたちを割当する$( %親 の`根$ ) ◎ Run assign slottables for a tree with parent’s root.
- `~treeに~slottableたちを割当する$( %~node ) ◎ Run assign slottables for a tree with node.
- `除去-時の手続き$に ( %~node, %親 ) を渡して走らす ◎ Run the removing steps with node and parent.
- %親は接続されている ~LET [ %親 は`接続されて$いるならば ~T / ~ELSE_ ~F ] ◎ Let isParentConnected be parent’s connected.
-
~IF[ %~node は`~custom$である ]~AND[ %親は接続されている ~EQ ~T ] ⇒ `~custom要素~callback反応を~enqueueする$( %~node, `disconnectedCallback^l, 空~list ) ◎ If node is custom and isParentConnected is true, then enqueue a custom element callback reaction with node, callback name "disconnectedCallback", and an empty argument list.
注記: 今の所,`~custom$である`要素$には %親 を渡さないのは意図的であるが、将来に必要になった場合は変更され得る。 ◎ It is intentional for now that custom elements do not get parent passed. This might change in the future if there is a need.
-
%~node の ~EACH( `~shadowも含む子孫$ %子孫 ) に対し,`~shadowも含む~tree順序$で: ◎ For each shadow-including descendant descendant of node, in shadow-including tree order, then:
- `除去-時の手続き$に ( %子孫 ) を渡して走らす ◎ Run the removing steps with descendant.
- ~IF[ %子孫 は`~custom$である ]~AND[ %親は接続されている ~EQ ~T ] ⇒ `~custom要素~callback反応を~enqueueする$( %子孫, `disconnectedCallback^l, 空~list ) ◎ If descendant is custom and isParentConnected is true, then enqueue a custom element callback reaction with descendant, callback name "disconnectedCallback", and an empty argument list.
- %親 の ~EACH( `広義先祖$ %広義先祖 ) に対し ⇒ %広義先祖 の`登録-済み観測器~list$内の ~EACH( %登録-済み ) に対し ⇒ ~IF[ %登録-済み の`~options$obの $MutationObserverInit.subtree ~EQ ~T ] ⇒ %~node の`登録-済み観測器~list$に 次のように設定された新たな`一時~登録-済み観測器$を`付加する$ ⇒# `観測器$ob ~SET %登録-済み の`観測器$ob, `~options$ob ~SET %登録-済み の`~options$ob, `~source$ob ~SET %登録-済み ◎ For each inclusive ancestor inclusiveAncestor of parent, and then for each registered of inclusiveAncestor’s registered observer list, if registered’s options’s subtree is true, then append a new transient registered observer whose observer is registered’s observer, options is registered’s options, and source is registered to node’s registered observer list.
- ~IF[ %観測器は抑止する~flag ~NEQ ε ] ⇒ %親 用に`~tree変異~記録を~queueする$( « », « %~node », %前-同胞, %次-同胞 ) ◎ If suppress observers flag is unset, then queue a tree mutation record for parent with « », « node », oldPreviousSibling, and oldNextSibling.
4.2.4. ^@NonElementParentNode ~mixin
注記: ~Web互換性のため、 $getElementById() ~methodは,`要素$ 上には(したがって $ParentNode 上にも)公開できない。 ◎ Web compatibility prevents the getElementById() method from being exposed on elements (and therefore on ParentNode).
!! interface mixin @NonElementParentNode { $Element? $getElementById($DOMString %elementId); }; $Document includes $NonElementParentNode; $DocumentFragment includes $NonElementParentNode; !- %node . $getElementById(elementId)
- %node の`子孫$であって, `~ID$ ~EQ %elementId なる`要素$のうち,`最初のもの?$を返す。 ◎ Returns the first element within node’s descendants whose ID is elementId.
4.2.5. ^@DocumentOrShadowRoot ~mixin
!! interface mixin @DocumentOrShadowRoot { }; $Document includes $DocumentOrShadowRoot; $ShadowRoot includes $DocumentOrShadowRoot; !注記: $DocumentOrShadowRoot ~mixinは、[ `文書$, `~shadow根$ ]で共有される~APIを定義したいと求める他の標準により利用されることが期待されている。 ◎ The DocumentOrShadowRoot mixin is expected to be used by other standards that want to define APIs shared between documents and shadow roots.
4.2.6. ^@ParentNode ~mixin
`~nodeたちを~nodeに変換する@ 手続きは、所与の ( %nodes, %文書 ) に対し,次を走らす: ◎ To convert nodes into a node, given nodes and document, run these steps:
【 %nodes は、~nodeと文字列が混在する引数~list。 】
- %nodes 内の ~EACH( 文字列 %文字列 ) を `新たな~Text~node$( %文字列, %文書 ) に置換する ◎ Let node be null. ◎ Replace each string in nodes with a new Text node whose data is the string and node document is document.
- ~IF[ %nodes に含まれる`~node$は 1 個だけ ] ⇒ ~RET その`~node$ ◎ If nodes contains one node, set node to that node.
- %文書片 ~LET 新たな`文書片$ ◎ Otherwise, set node to a new DocumentFragment\
- %文書片 の`~node文書$ ~SET %文書 ◎ whose node document is document, and then\
- %nodes 内の ~EACH( %node ) に対し ⇒ %文書片 に`~nodeを付加する$( %node ) ◎ append each node in nodes, if any, to it.
- ~RET %文書片 ◎ Return node.
- %collection = %node . $children
- `子$である`要素$をすべて返す。 ◎ Returns the child elements.
- %element = %node . $firstElementChild
- `子$である`要素$のうち,`最初のもの?$を返す。 ◎ Returns the first child that is an element, and null otherwise.
- %element = %node . $lastElementChild
- `子$である`要素$のうち,`最後のもの?$を返す。 ◎ Returns the last child that is an element, and null otherwise.
- %node . $prepend(nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %nodes を %node の`最初の子?$の前に挿入する。 ◎ Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
- `~node~tree$の拘束に反する場合、 `HierarchyRequestError$E が`投出$される。 ◎ Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
- %node . $append(nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %nodes を %node の`最後の子?$の後に挿入する。 ◎ Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
- %node . $replaceChildren(nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %node の`子たち$すべてを %nodes で置換する。 ◎ Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes.
- %node . $querySelector(selectors)
- %node の`子孫$であって, %selectors に合致する`要素$のうち,`最初のもの?$を返す。 ◎ Returns the first element that is a descendant of node that matches selectors.
- %node . $querySelectorAll(selectors)
- %node の`子孫$であって, %selectors に合致する,すべての`要素$を返す。 ◎ Returns all element descendants of node that match selectors.
@prepend(nodes) ~method~手続きは: ◎ The prepend(nodes) method, when invoked, must run these steps:
- %node ~LET `~nodeたちを~nodeに変換する$( %nodes, コレの`~node文書$ ) ◎ Let node be the result of converting nodes into a node given nodes and this’s node document.
- コレの中で`~nodeを子の前に前挿入する$( %node, コレの`最初の子?$ ) ◎ Pre-insert node into this before this’s first child.
@append(nodes) ~method~手続きは: ◎ The append(nodes) method, when invoked, must run these steps:
- コレに`~nodeを付加する$( %node ) ◎ Append node to this.
@replaceChildren(nodes) ~method~手続きは: ◎ The replaceChildren(nodes) method, when invoked, must run these steps:
- %node ~LET `~nodeたちを~nodeに変換する$( %nodes, コレの`~node文書$ ) ◎ Let node be the result of converting nodes into a node given nodes and this’s node document.
- %node をコレの中で ~NULL の前に`挿入できるかどうか検証する$ ◎ Ensure pre-insertion validity of node into this before null.
- コレの`全~内容を~nodeで置換する$( %node ) ◎ Replace all with node within this.
4.2.7. ^@NonDocumentTypeChildNode ~mixin
注記: ~Web互換性のため、 $previousElementSibling, $nextElementSibling 属性は,`~doctype$上には(したがって, $ChildNode 上にも)公開できない。 ◎ Web compatibility prevents the previousElementSibling and nextElementSibling attributes from being exposed on doctypes (and therefore on ChildNode).
!! interface mixin @NonDocumentTypeChildNode { ~RA $Element? $previousElementSibling; ~RA $Element? $nextElementSibling; }; $Element includes $NonDocumentTypeChildNode; $CharacterData includes $NonDocumentTypeChildNode; !- %element = %node . $previousElementSibling
- `先行-$する`同胞$の`要素$のうち,`最後のもの?$を返す。 ◎ Returns the first preceding sibling that is an element, and null otherwise.
- %element = %node . $nextElementSibling
- `後続-$する`同胞$の`要素$のうち,`最初のもの?$を返す。 ◎ Returns the first following sibling that is an element, and null otherwise.
4.2.8. ^@ChildNode ~mixin
!! interface mixin @ChildNode { [`CEReactions$, `Unscopable$] $undefined $before(($Node or $DOMString)... %nodes); [`CEReactions$, `Unscopable$] $undefined $after(($Node or $DOMString)... %nodes); [`CEReactions$, `Unscopable$] $undefined $replaceWith(($Node or $DOMString)... %nodes); [`CEReactions$, `Unscopable$] $undefined $remove(); }; $DocumentType includes $ChildNode; $Element includes $ChildNode; $CharacterData includes $ChildNode; !- %node . $before(...nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %nodes を %node の直前に挿入する。 ◎ Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
- %node . $after(...nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %nodes を %node の直後に挿入する。 ◎ Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes.
- %node . $replaceWith(...nodes)
- %nodes 内の各 文字列は等価な $Text `~node$に置換した上で、 %node を %nodes に置換する。 ◎ Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes.
- %node . $remove()
- %node を除去する。 ◎ Removes node.
@before(nodes) ~method~手続きは: ◎ The before(nodes) method, when invoked, must run these steps:
- %親 ~LET コレの`親$ ◎ Let parent be this’s parent.
- ~IF[ %親 ~EQ ~NULL ] ⇒ ~RET ◎ If parent is null, then return.
- %およそ前-同胞 ~LET 次を満たす~nodeのうち,`最後のもの?$ ⇒ [ コレの`同胞$である ]~AND[ コレに`先行-$する ]~AND[ ~node ~NIN %nodes に与えられた引数の集合 ] ◎ Let viablePreviousSibling be this’s first preceding sibling not in nodes, and null otherwise.
- %およそ前-同胞 ~SET [ %およそ前-同胞 ~EQ ~NULL ならば %親 の`最初の子?$ / ~ELSE_ %およそ前-同胞 の`次-同胞?$ ] ◎ If viablePreviousSibling is null, set it to parent’s first child, and to viablePreviousSibling’s next sibling otherwise.
- %親 の中で`~nodeを子の前に前挿入する$( %node, %およそ前-同胞 ) ◎ Pre-insert node into parent before viablePreviousSibling.
@after(nodes) ~method~手続きは: ◎ The after(nodes) method, when invoked, must run these steps:
- %およそ次-同胞 ~LET 次を満たす~nodeのうち,`最初のもの?$ ⇒ [ コレの`同胞$である ]~AND[ コレに`後続-$する ]~AND[ ~node ~NIN %nodes に与えられた引数の集合 ] ◎ Let viableNextSibling be this’s first following sibling not in nodes, and null otherwise.
- %親 の中で`~nodeを子の前に前挿入する$( %node, %およそ次-同胞 ) ◎ Pre-insert node into parent before viableNextSibling.
@replaceWith(nodes) ~method~手続きは: ◎ The replaceWith(nodes) method, when invoked, must run these steps:
-
~IF[ コレの`親$ ~EQ %親 ] ⇒ %親 の中で`子を~nodeに置換する$( コレ, %node ) ◎ If this’s parent is parent, replace this with node within parent.
注記: コレは %node の中に挿入されていることもある。 ◎ This could have been inserted into node.
- ~ELSE ⇒ %親 の中で`~nodeを子の前に前挿入する$( %node, %およそ次-同胞 ) ◎ Otherwise, pre-insert node into parent before viableNextSibling.
@remove() ~method~手続きは: ◎ The remove() method, when invoked, must run these steps:
- ~IF[ コレの`親$ ~EQ ~NULL ] ⇒ ~RET ◎ If this’s parent is null, then return.
- `~nodeを除去する$( コレ ) ◎ Remove this.
4.2.9. ^@Slottable ~mixin
!! interface mixin @Slottable { ~RA $HTMLSlotElement? $assignedSlot; }; $Element includes $Slottable; $Text includes $Slottable; !4.2.10. 旧式な~collection: ^NodeList と ^HTMLCollection
`~collection@ は`~node$の~listを表現する~objである。 `~collection$は `~live@ にも `静的@ にもなり得る。 他が言明されない限り、`~collection$は`~live$になるモノトスル。 ◎ A collection is an object that represents a list of nodes. A collection can be either live or static. Unless otherwise stated, a collection must be live.
`~live$である`~collection$の[ 属性/~method ]は、~dataの~snapshotではなく 実際の下層~data†に対し,演算するモノトスル††。 ◎ If a collection is live, then the attributes and methods on that object must operate on the actual underlying data, not a snapshot of the data.
【† すなわち、作成-時の~data(~snapshot)ではなく,~accessされた時点における~data 】【†† 従って,~collectionの走査-中に~treeを改変するときは、~collectionの無限増殖に陥いらないよう注意する必要がある。 】【 `静的$とされている場合は,逆に、~dataの~snapshotに対し演算することになる。 】
各 `~collection$の作成-時には、次に挙げるものが結付けられる:
- `根@cL
- ~collectionの視野を与える。
- `~filter@cL
- ~nodeが~collectionに含められるための条件を与える。
`~collection$は、[ その`根$cLを根とする下位treeの中で,所与の`~filter$cLに合致する`~node$ ]のみを含むような~viewを `表現-@ する。 この~viewは全順序である — `~collection$に含められる~nodeたちは、他の要件が指定されない限り,`~tree順序$に~sortするモノトスル。 ◎ The collection then represents a view of the subtree rooted at the collection’s root, containing only nodes that match the given filter. The view is linear. In the absence of specific requirements to the contrary, the nodes within the collection must be sorted in tree order.
【 ほとんどの~collectionでは,`根$cL自身は`~filter$cLに合致しないが、 $NodeIterator の`反復子~collection$など,そうでないものもある。 】
4.2.10.1. ^@NodeList ~interface
$NodeList ~objは`~node$の`~collection$である。 ◎ A NodeList object is a collection of nodes.
!! [`Exposed$=Window] interface @NodeList { getter $Node? $item(`unsigned long$ %index); ~RA `unsigned long$ $length; iterable<$Node>; }; !- %collection . $length
- `~collection$に含まれている`~node$の個数を返す。 ◎ Returns the number of nodes in the collection.
- %element = %collection . $item(index)
- %element = %collection[%index]
- `~tree順序$に~sortされた下で、`~collection$の中で, %index 番の`~node$を返す。 ◎ Returns the node with index index from the collection. The nodes are sorted in tree order.
~collection %O が`~supportする~prop~index$は、 0 以上[ %O が`表現-$する~nodeの個数 ]未満とする。 ◎ The object’s supported property indices are the numbers in the range zero to one less than the number of nodes represented by the collection. If there are no such elements, then there are no supported property indices.
4.2.10.2. ^@HTMLCollection ~interface
!! [`Exposed$=Window, `LegacyUnenumerableNamedProperties$] interface @HTMLCollection { ~RA `unsigned long$ $length; getter $Element? $item(`unsigned long$ %index); getter $Element? $namedItem($DOMString %name); }; !$HTMLCollection ~objは`要素$の`~collection$である。 ◎ An HTMLCollection object is a collection of elements.
注記:
$HTMLCollection は、歴史的な~~理由から~~廃するわけにいかない所産である。
開発者は それを利用し続けても構わないが、新たな~API標準の設計者は それを利用しないこと(代わりに~IDL $sequence<%T>
型を利用すること)。
◎
HTMLCollection is a historical artifact we cannot rid the web of. While developers are of course welcome to keep using it, new API standard designers ought not to use it (use sequence<T> in IDL instead).
- %collection . $length
- `~collection$に含まれている`要素$の個数を返す。 ◎ Returns the number of elements in the collection.
- %element = %collection . $item(index)
- %element = %collection[%index]
- `要素$たちを`~tree順序$に~sortした下での、`~collection$の中で %index 番の`要素$を返す。 ◎ Returns the element with index index from the collection. The elements are sorted in tree order.
- %element = %collection . $namedItem(name)
- %element = %collection[%name]
- `~collection$の中で `~ID$ または名前が %name なる最初の`要素$を返す。 ◎ Returns the first element with ID or name name from the collection.
`~collection$ %O が`~supportする~prop~index$は、 0 以上[ %O が`表現-$する要素の個数 ]未満とする。 ◎ The object’s supported property indices are the numbers in the range zero to one less than the number of elements represented by the collection. If there are no such elements, then there are no supported property indices.
`~collection$ %O が`~supportする~prop名$たちは、次の手続きの結果で与えられる: ◎ The supported property names are the values from the list returned by these steps:
- %結果 ~LET 空~list ◎ Let result be an empty list.
-
%O が`表現-$する ~EACH( 要素 %要素 ) に対し,`~tree順序$で: ◎ For each element represented by the collection, in tree order:
- ~IF[ %要素 は `~ID$ %id を持つ ]~AND[ %id ~NIN %結果 ] ⇒ %結果 に %id を付加する ◎ If element has an ID which is not in result, append element’s ID to result.
- ~IF[ %要素 は`~HTML~ns$に属する ]~AND[ %要素 の`属性o~list$内に `name^A `属性o$nmは在る ]~AND[ その属性oの`値$a %name ~NEQ 空~文字列 ]~AND[ %name ~NIN %結果 ] ⇒ %結果 に %name を付加する ◎ If element is in the HTML namespace and has a name attribute whose value is neither the empty string nor is in result, append element’s name attribute value to result.
- ~RET %結果 ◎ Return result.
@namedItem(name) ~method~手続きは: ◎ The namedItem(key) method, when invoked, must run these steps:
- ~IF[ %name ~EQ 空~文字列 ] ⇒ ~RET ~NULL ◎ If key is the empty string, return null.
-
~RET コレが`表現-$する`要素$たちのうち,次のいずれかを満たす`最初のもの?$:
- `~ID$ ~EQ %name
- [ `~HTML~ns$に属する ]~AND[ `属性o~list$内に次を満たす属性oが在る ] ⇒ [ `name^A `属性o$nmである ]~AND[ `値$a ~EQ %name ]
4.3. 変異~観測器
各 `生成元が類似な~window~agent$ `HTML$r には、次に挙げるものが結付けられる:
- `変異~観測器 小task~queue済み@
- 真偽値 — 初期~時は ~F とする。
- `変異~観測器たち@
- 0 個以上の $MutationObserver ~objからなる`有順序~集合$ — 初期~時は空とする。
`変異~観測器 小taskを~queueする@ ときは、次を走らす: ◎ To queue a mutation observer microtask, run these steps:
- ~IF[ `~surrounding~agent$の`変異~観測器 小task~queue済み$ ~EQ ~T ] ⇒ ~RET ◎ If the surrounding agent’s mutation observer microtask queued is true, then return.
- `~surrounding~agent$の`変異~観測器 小task~queue済み$ ~SET ~T ◎ Set the surrounding agent’s mutation observer microtask queued to true.
- 次を走らす`小taskを~queueする$ ⇒ `変異~観測器に通知する$ ◎ Queue a microtask to notify mutation observers.
`変異~観測器に通知する@ ときは、次を走らす: ◎ To notify mutation observers, run these steps:
- `~surrounding~agent$の`変異~観測器 小task~queue済み$ ~SET ~F ◎ Set the surrounding agent’s mutation observer microtask queued to false.
- %通知-集合 ~LET `~surrounding~agent$の`変異~観測器たち$を`~cloneする$ ◎ Let notifySet be a clone of the surrounding agent’s mutation observers.
- %通達~slot集合 ~LET `~surrounding~agent$の`通達~slotたち$を`~cloneする$ ◎ Let signalSet be a clone of the surrounding agent’s signal slots.
- `~surrounding~agent$の`通達~slotたち$を`空にする$ ◎ Empty the surrounding agent’s signal slots.
-
%通知-集合 を成す ~EACH( %MO ) に対し: ◎ For each mo of notifySet:
- %記録たち ~LET %MO の`記録~queue$moを`~cloneする$ ◎ Let records be a clone of mo’s record queue.
- %MO の`記録~queue$moを`空にする$ ◎ Empty mo’s record queue.
- %MO の`~node~list$mo内の ~EACH( %~node ) に対し ⇒ %~node の`登録-済み観測器~list$から 次を満たす`一時~登録-済み観測器$をすべて`除去する$ ⇒ その`観測器$ob ~EQ %MO ◎ For each node of mo’s node list, remove all transient registered observers whose observer is mo from node’s registered observer list.
- ~IF[ %記録たち は`空$でない ] ⇒ `~callback関数を呼出す$( %MO の`~callback$mo, « %記録たち, %MO », %MO ) ⇒ 例外が投出されたときは、~catchして ⇒ `その例外を報告する$ ◎ If records is not empty, then invoke mo’s callback with « records, mo », and mo. If this throws an exception, catch it, and report the exception.
- %通達~slot集合 を成す ~EACH( `~slot$ %~slot ) に対し ⇒ %~slot に向けて名前 `slotchange$et の`~eventを発火する$ — 次のように初期化して ⇒ $Event.bubbles 属性 ~SET ~T ◎ For each slot of signalSet, fire an event named slotchange, with its bubbles attribute set to true, at slot.
各 `~node$には、 `登録-済み観測器~list@ が結付けられる — それは、 0 個~以上の`登録-済み観測器$からなる`~list$であり,初期~時には空とする。 【この~nodeにおける変異を観測している観測器たちを表す。】 ◎ Each node has a registered observer list (a list of zero or more registered observers), which is initially empty.
各 `登録-済み観測器@ は、次に挙げるものからなる:
- `観測器@ob
- $MutationObserver ~obj。
- `~options@ob
- $MutationObserverInit 辞書。
`一時~登録-済み観測器@ は、上述に加えて 次に挙げるものも持つ,`登録-済み観測器$である:
- `~source@ob
- `登録-済み観測器$。
注記: `一時~登録-済み観測器$は、所与の`~node$に対し,それが除去された後も`~node$の`子孫$における変異を追跡するために利用される — これにより、`~node$の`親$にて $MutationObserverInit.subtree が ~T に設定されているときでも,それらの変異は失われずに済む。 ◎ Transient registered observers are used to track mutations within a given node’s descendants after node has been removed so they do not get lost when subtree is set to true on node’s parent.
4.3.1. ^@MutationObserver ~interface
!! [`Exposed$=Window] interface @MutationObserver { `MutationObserver$mc($MutationCallback %callback); $undefined $observe($Node %target, optional $MutationObserverInit %options = {}); $undefined $disconnect(); $sequence<$MutationRecord> $takeRecords(); }; callback @MutationCallback = $undefined ($sequence<$MutationRecord> %mutations, $MutationObserver %observer); dictionary @@MutationObserverInit { $boolean @childList = false; $boolean @attributes; $boolean @characterData; $boolean @subtree = false; $boolean @attributeOldValue; $boolean @characterDataOldValue; $sequence<$DOMString> @attributeFilter; }; !$MutationObserver ~objを利用すれば、`~node$が成す`~tree$における変異を観測できる。 ◎ A MutationObserver object can be used to observe mutations to the tree of nodes.
各 $MutationObserver ~objには、次の概念が結付けられる: ◎ Each MutationObserver object has these associated concepts:
- `~callback@mo
- ~callback関数。 ~objの作成-時に設定される。 ◎ A callback set on creation.
- `~node~list@mo
- 0 個以上の`~node$からなる`~list$。 初期~時は空とする。 ◎ A node list (a list of nodes), which is initially empty.
- `記録~queue@mo
- 0 個以上の $MutationRecord ~objからなる`~queue$ — 初期~時は空とする。 ◎ A record queue (a queue of zero or more MutationRecord objects), which is initially empty.
- %observer = $MutationObserver(callback)
- $MutationObserver ~objを構築し,その`~callback$moを %callback に設定する。 %callback は、その 1 個目, 2 個目の引数に ( $MutationRecord ~objの~list, 構築された %observer ) が渡されて呼出される。 %callback は、 $observe() ~methodにより登録-済みにされた`~node$が変異したとき(した後)に,呼出される。 ◎ Constructs a MutationObserver object and sets its callback to callback. The callback is invoked with a list of MutationRecord objects as first argument and the constructed MutationObserver object as second argument. It is invoked after nodes registered with the observe() method, are mutated.
- %observer . $observe(target, options)
- %target ( `~node$ )を観測して, %options ( ~obj)に与えた判定基準に基づいて変異を報告するよう、~UAに指図する。 ◎ Instructs the user agent to observe a given target (a node) and report any mutations based on the criteria given by options (an object).
-
%options 引数に与えた~objの各~memberを介して,観測させる変異についての~optionを設定できる。 利用できる~obj~memberは: ◎ The options argument allows for setting mutation observation options via object members. These are the object members that can be used:
- $childList
- %target の`子たち$の変異を観測するときは、 ~T にする。 ◎ Set to true if mutations to target’s children are to be observed.
- $attributes
- %target の`属性o$の変異を観測するときは、 ~T にする。 $attributeOldValue または $attributeFilter を指定している場合は、省略できる。 ◎ Set to true if mutations to target’s attributes are to be observed. Can be omitted if attributeOldValue or attributeFilter is specified.
- $characterData
- %target の`~data$の変異を観測するときは、 ~T にする。 $characterDataOldValue を指定している場合は、省略できる。 ◎ Set to true if mutations to target’s data are to be observed. Can be omitted if characterDataOldValue is specified.
- $subtree
- %target のみならず, %target の`子孫$の変異も観測するときは、 ~T にする。 ◎ Set to true if mutations to not just target, but also target’s descendants are to be observed.
- $attributeOldValue
- $attributes を~T にしているか省略していて,かつ 変異~前の %target の`属性o$ `値$aを記録しておく必要がある場合は、 ~T にする。 ◎ Set to true if attributes is true or omitted and target’s attribute value before the mutation needs to be recorded.
- $characterDataOldValue
- $characterData を~T にしているか省略していて,かつ 変異~前の %target の`~data$を記録しておく必要がある場合は、 ~T にする。 ◎ Set to true if characterData is set to true or omitted and target’s data before the mutation needs to be recorded.
- $attributeFilter
- $attributes を ~T にしているか省略していて,かつ すべての`属性o$の変異を観測する必要はない場合は、必要な`属性o$の(`~ns$a のない)`局所~名$aの~listを与える。 ◎ Set to a list of attribute local names (without namespace) if not all attribute mutations need to be observed and attributes is true or omitted.
- %observer . $disconnect()
- %observer による変異の観測を停止する。 $observe() ~methodが再び利用されるまで, %observer の`~callback$moは呼出されないことになる。 ◎ Stops observer from observing any mutations. Until the observe() method is used again, observer’s callback will not be invoked.
- %observer . $takeRecords()
- `記録~queue$moを空にして,空にする前の内容を返す。 ◎ Empties the record queue and returns what was in there.
@MutationObserver(callback) 構築子~手続きは: ◎ The MutationObserver(callback) constructor, when invoked, must run these steps:
- コレの`~callback$mo ~SET %callback ◎ Let mo be a new MutationObserver object whose callback is callback.
- [ コレに`関連な~agent$の`変異~観測器たち$ ]にコレを`付加する$set ◎ Append mo to mo’s relevant agent’s mutation observers. ◎ Return mo.
@observe(target, options) ~method~手続きは: ◎ The observe(target, options) method, when invoked, must run these steps:
- ~IF[[ %options[ "$attributeOldValue" ] ~NEQ ε ]~OR[ %options[ "$attributeFilter" ] ~NEQ ε ]]~AND[ %options[ "$attributes" ] ~EQ ε ] ⇒ %options[ "$attributes" ] ~SET ~T ◎ If either options’s attributeOldValue or attributeFilter is present and options’s attributes is omitted, then set options’s attributes to true.
- ~IF[ %options[ "$characterDataOldValue" ] ~NEQ ε ]~AND[ %options[ "$characterData" ] ~EQ ε ] ⇒ %options[ "$characterData" ] ~SET ~T ◎ If options’s characterDataOldValue is present and options’s characterData is omitted, then set options’s characterData to true.
-
~IF[ 次のいずれかが満たされる ] ⇒ ~THROW `TypeError$E : ◎ ↓
- [ %options[ "$childList" ] ~EQ ~F ]~AND[ %options[ "$attributes" ] ~EQ ~F ]~AND[ %options[ "$characterData" ] ~EQ ~F ] ◎ If none of options’s childList, attributes, and characterData is true, then throw a TypeError.
- [ %options[ "$attributeOldValue" ] ~EQ ~T ]~AND[ %options[ "$attributes" ] ~EQ ~F ] ◎ If options’s attributeOldValue is true and options’s attributes is false, then throw a TypeError.
- [ %options[ "$attributeFilter" ] ~NEQ ε ]~AND[ %options[ "$attributes" ] ~EQ ~F ] ◎ If options’s attributeFilter is present and options’s attributes is false, then throw a TypeError.
- [ %options[ "$characterDataOldValue" ] ~EQ ~T ]~AND[ %options[ "$characterData" ] ~EQ ~F ] ◎ If options’s characterDataOldValue is true and options’s characterData is false, then throw a TypeError.
- %登録-済み~list ~LET %target の`登録-済み観測器~list$内の次を満たす`登録-済み観測器$からなる~list ⇒ その`観測器$ob ~EQ コレ ◎ For each registered of target’s registered observer list, if registered’s observer is this:
-
%登録-済み~list 内の ~EACH( %登録-済み ) に対し: ◎ ↑
- コレの`~node~list$mo内の ~EACH( %~node ) に対し ⇒ %~node の`登録-済み観測器~list$から 次を満たす`一時~登録-済み観測器$をすべて`除去する$ ⇒ その`~source$ob ~EQ %登録-済み ◎ For each node of this’s node list, remove all transient registered observers whose source is registered from node’s registered observer list.
- %登録-済み の`~options$ob ~SET %options ◎ Set registered’s options to options.
-
~IF[ %登録-済み~list は空である ]: ◎ Otherwise:
- %target の`登録-済み観測器~list$に[ 次のように設定された新たな`登録-済み観測器$ ]を`付加する$ ⇒# `観測器$ob ~SET コレ, `~options$ob ~SET %options ◎ Append a new registered observer whose observer is this and options is options to target’s registered observer list.
- コレの`~node~list$moに %target を`付加する$ ◎ Append target to this’s node list.
@disconnect() ~method~手続きは: ◎ The disconnect() method, when invoked, must run these steps:
- コレの`~node~list$mo内の ~EACH( %~node ) に対し ⇒ %~node の`登録-済み観測器~list$から,次を満たす`登録-済み観測器$をすべて除去する ⇒ その`観測器$ob ~EQ コレ ◎ For each node of this’s node list, remove any registered observer from node’s registered observer list for which this is the observer.
- コレの`記録~queue$moを`空にする$ ◎ Empty this’s record queue.
@takeRecords() ~method~手続きは: ◎ The takeRecords() method, when invoked, must run these steps:
- %記録たち ~LET コレの`記録~queue$moを`~cloneする$ ◎ Let records be a clone of this’s record queue.
- コレの`記録~queue$moを`空にする$ ◎ Empty this’s record queue.
- ~RET %記録たち ◎ Return records.
4.3.2. 変異~記録を~queueする
%~target 用に ある %種別 の `変異~記録を~queueする@ ときは、所与の ( %名前, %~ns, %旧-値, %追加-済み~nodeたち, %除去-済み~nodeたち, %前-同胞, %次-同胞 ) に対し,次を走らす: ◎ To queue a mutation record of type for target with name, namespace, oldValue, addedNodes, removedNodes, previousSibling, and nextSibling, run these steps:
- %有関係~観測器たち ~LET 新たな`~map$ ◎ Let interestedObservers be an empty map.
- %nodes ~LET %~target のすべての`広義先祖$ ◎ Let nodes be the inclusive ancestors of target.
-
%nodes 内の ~EACH( %node ) に対し 【順序は?】 ⇒ %node の`登録-済み観測器~list$内の ~EACH( %登録-済み ) に対し: ◎ For each node in nodes, and then for each registered of node’s registered observer list:
- %options ~LET %登録-済み の`~options$ob ◎ Let options be registered’s options.
-
~IF[ 次のいずれかが満たされる ] ⇒ ~CONTINUE: ◎ If none of the following are true
- [ %node ~NEQ %~target ]~AND[ %options[ "$subtree" ] ~EQ ~F ] ◎ node is not target and options’s subtree is false
- [ %種別 ~EQ `attributes^l ]~AND[ %options[ "$attributes" ] ~NEQ ~T ] ◎ type is "attributes" and options’s attributes is not true
-
次がすべて満たされる:
- %種別 ~EQ `attributes^l
- %options[ "$attributeFilter" ] ~NEQ ε
- [ %名前 ~NIN %options[ "$attributeFilter" ] ]~OR[ %~ns ~NEQ ~NULL ]
- [ %種別 ~EQ `characterData^l ]~AND[ %options[ "$characterData" ] ~NEQ ~T ] ◎ type is "characterData" and options’s characterData is not true
- [ %種別 ~EQ `childList^l ]~AND[ %options[ "$childList" ] ~EQ ~F ] ◎ type is "childList" and options’s childList is false
- %MO ~LET %登録-済み の`観測器$ob ◎ then: ◎ Let mo be registered’s observer.
- ~IF[ %有関係~観測器たち[ %MO ] ~EQ ε ] ⇒ %有関係~観測器たち[ %MO ] ~SET ~NULL ◎ If interestedObservers[mo] does not exist, then set interestedObservers[mo] to null.
-
~IF[ 次のいずれかが満たされる ]…: ◎ If either\
- [ %種別 ~EQ `attributes^l ]~AND[ %options[ "$attributeOldValue" ] ~EQ ~T ] ◎ type is "attributes" and options’s attributeOldValue is true, or\
- [ %種別 ~EQ `characterData^l ]~AND[ %options[ "$characterDataOldValue" ] ~EQ ~T ] ◎ type is "characterData" and options’s characterDataOldValue is true,\
…ならば ⇒ %有関係~観測器たち[ %MO ] ~SET %旧-値 ◎ then set interestedObservers[mo] to oldValue.
-
%有関係~観測器たち を成す ~EACH( %観測器 → %~map先の旧-値 ) に対し ⇒ %観測器 の`記録~queue$moに[ 次のように設定された新たな $@MutationRecord ~obj ]を`~enqueueする$ ⇒# $type ~SET %種別, $target ~SET %~target, $attributeName ~SET %名前, $attributeNamespace ~SET %~ns, $oldValue ~SET %~map先の旧-値, $addedNodes ~SET %追加-済み~nodeたち, $removedNodes ~SET %除去-済み~nodeたち, $previousSibling ~SET %前-同胞, $nextSibling ~SET %次-同胞, ◎ For each observer → mappedOldValue of interestedObservers: • Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue, addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling. • Enqueue record to observer’s record queue.
- `変異~観測器 小taskを~queueする$ ◎ Queue a mutation observer microtask.
%~target 用に `~tree変異~記録を~queueする@ ときは、所与の ( %追加-済み~nodeたち, %除去-済み~nodeたち, %前-同胞, %次-同胞 ) に対し,次を走らす: ◎ To queue a tree mutation record for target with addedNodes, removedNodes, previousSibling, and nextSibling, run these steps:
- ~Assert: [ %追加-済み~nodeたち は`空$でない ]~OR[ %除去-済み~nodeたち は`空$でない ] ◎ Assert: either addedNodes or removedNodes is not empty.
- %~target 用に種別 `childList^l の`変異~記録を~queueする$( 次に挙げる引数 ) ⇒# ~NULL, ~NULL, ~NULL, %追加-済み~nodeたち, %除去-済み~nodeたち, %前-同胞, %次-同胞 ◎ Queue a mutation record of "childList" for target with null, null, null, addedNodes, removedNodes, previousSibling, and nextSibling.
4.3.3. ^@MutationRecord ~interface
!! [`Exposed$=Window] interface @MutationRecord { ~RA $DOMString $type; [`SameObject$] ~RA $Node $target; [`SameObject$] ~RA $NodeList $addedNodes; [`SameObject$] ~RA $NodeList $removedNodes; ~RA $Node? $previousSibling; ~RA $Node? $nextSibling; ~RA $DOMString? $attributeName; ~RA $DOMString? $attributeNamespace; ~RA $DOMString? $oldValue; }; !- %record . $type
- 変異の種類に応じて,次を返す ⇒# `属性o$に対する変異であった場合は `attributes^l, $CharacterData `~node$に対する変異であった場合は `characterData^l, `~node$が成す`~tree$に対する変異であった場合は `childList^l ◎ Returns "attributes" if it was an attribute mutation. "characterData" if it was a mutation to a CharacterData node. And "childList" if it was a mutation to the tree of nodes.
- %record . $target
- 変異に影響された`~node$を返す — $type に応じて ⇒# `attributes^l に対しては,`属性o$が変化した`要素$ / `characterData^l に対しては,$CharacterData `~node$ / `childList^l に対しては,`子たち$が変化した`~node$ ◎ Returns the node the mutation affected, depending on the type. For "attributes", it is the element whose attribute changed. For "characterData", it is the CharacterData node. For "childList", it is the node whose children changed.
- %record . $addedNodes
- %record . $removedNodes
- 順に、[ 追加-, 除去- ]された`~node$の~listを返す。 ◎ Return the nodes added and removed respectively.
- %record . $previousSibling
- %record . $nextSibling
- 順に、追加-または除去された`~node$が在れば その[ `前-同胞?$, `次-同胞?$ ]を, 無ければ ~NULL を返す。 ◎ Return the previous and next sibling respectively of the added or removed nodes, and null otherwise.
- %record . $attributeName
- 変化した`属性o$が在れば その`局所~名$aを, 無ければ ~NULL を返す。 ◎ Returns the local name of the changed attribute, and null otherwise.
- %record . $attributeNamespace
- 変化した`属性o$が在れば その`~ns$を, 無ければ ~NULL を返す。 ◎ Returns the namespace of the changed attribute, and null otherwise.
- %record . $oldValue
- $type に応じて,次の値を返す ⇒# `attributes^l に対しては,変化した`属性o$の変化~前の`値$a。 `characterData^l に対しては,変化した`~node$の変化~前の`~data$。 `childList^l に対しては, ~NULL 。 ◎ The return value depends on type. For "attributes", it is the value of the changed attribute before the change. For "characterData", it is the data of the changed node before the change. For "childList", it is null.
4.3.4. ~garbage収集
所与の[ `~node$ %~node, %~node の`登録-済み観測器~list$に含まれる各`登録-済み観測器$ %登録-済み観測器 ]に対しては ⇒# %~node は %登録-済み観測器 への強い参照を持つ / %登録-済み観測器 は %~node への弱い参照を持つ ◎ Nodes have a strong reference to registered observers in their registered observer list. ◎ Registered observers in a node’s registered observer list have a weak reference to the node.
4.4. ^@Node ~interface
!! [`Exposed$=Window] interface @Node : $EventTarget { const `unsigned short$ $ELEMENT_NODE = 1; const `unsigned short$ $ATTRIBUTE_NODE = 2; const `unsigned short$ $TEXT_NODE = 3; const `unsigned short$ $CDATA_SECTION_NODE = 4; const `unsigned short$ @ENTITY_REFERENCE_NODE = 5; // const `unsigned short$ @ENTITY_NODE = 6; // const `unsigned short$ $PROCESSING_INSTRUCTION_NODE = 7; const `unsigned short$ $COMMENT_NODE = 8; const `unsigned short$ $DOCUMENT_NODE = 9; const `unsigned short$ $DOCUMENT_TYPE_NODE = 10; const `unsigned short$ $DOCUMENT_FRAGMENT_NODE = 11; const `unsigned short$ @NOTATION_NODE = 12; // ~RA `unsigned short$ $nodeType; ~RA $DOMString $nodeName; ~RA $USVString $baseURI; ~RA $boolean $isConnected; ~RA $Document? $ownerDocument; $Node $getRootNode(optional $GetRootNodeOptions %options = {}); ~RA $Node? $parentNode; ~RA $Element? $parentElement; $boolean $hasChildNodes(); [`SameObject$] ~RA $NodeList $childNodes; ~RA $Node? $firstChild; ~RA $Node? $lastChild; ~RA $Node? $previousSibling; ~RA $Node? $nextSibling; [`CEReactions$] attribute $DOMString? $nodeValue; [`CEReactions$] attribute $DOMString? $textContent; [`CEReactions$] $undefined $normalize(); [`CEReactions$, `NewObject$] $Node $cloneNode(optional $boolean %deep = false); $boolean $isEqualNode($Node? %otherNode); $boolean $isSameNode($Node? %otherNode); // `===^c 演算子の旧来の別名 const `unsigned short$ $DOCUMENT_POSITION_DISCONNECTED = 0x01; const `unsigned short$ $DOCUMENT_POSITION_PRECEDING = 0x02; const `unsigned short$ $DOCUMENT_POSITION_FOLLOWING = 0x04; const `unsigned short$ $DOCUMENT_POSITION_CONTAINS = 0x08; const `unsigned short$ $DOCUMENT_POSITION_CONTAINED_BY = 0x10; const `unsigned short$ $DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; `unsigned short$ $compareDocumentPosition($Node %other); $boolean $contains($Node? %other); $DOMString? $lookupPrefix($DOMString? %namespace); $DOMString? $lookupNamespaceURI($DOMString? %prefix); $boolean $isDefaultNamespace($DOMString? %namespace); [`CEReactions$] $Node $insertBefore($Node %node, $Node? %child); [`CEReactions$] $Node $appendChild($Node %node); [`CEReactions$] $Node $replaceChild($Node %node, $Node %child); [`CEReactions$] $Node $removeChild($Node %child); }; dictionary @@GetRootNodeOptions { $boolean @composed = false; }; !注記: $@Node は抽象-~interfaceであり,`~node$として存在することはない。 それは、すべての`~node$( $Document, $DocumentType, $DocumentFragment, $Element, $Text, $ProcessingInstruction, $Comment )から利用される。 ◎ Node is an abstract interface and does not exist as node. It is used by all nodes (Document, DocumentType, DocumentFragment, Element, Text, ProcessingInstruction, and Comment).
【 $Attr も $Node を継承しているが、定義により,~treeには`関与-$しないことに注意。 ( “^Attr `~node$” という語も何箇所かに現れていて紛らわしいが。) 】
各 `~node$には、次に挙げるものが結付けられる:
- `~node文書@
- `文書$。 作成-時に設定される。
注記: `~node$の`~node文書$は、`~nodeを受入する$~algoにより変更され得る。 ◎ A node’s node document can be changed by the adopt algorithm.
【 ~nodeが`文書~tree内$になくても,結付けられることになる。 】
`~node$ %node の`親~targetを取得する$ときは、[ %node の`割当先~slot$ ~NEQ ~NULL ならば それ / ~ELSE_ %node の`親$ ]を返す。 ◎ A node’s get the parent algorithm, given an event, returns the node’s assigned slot, if node is assigned, and node’s parent otherwise.
【 `文書$は、~nodeの`親~targetを取得する$~algoを上書きする。 】
注記: 各`~node$は、`登録-済み観測器~list$も有する。 ◎ Each node also has a registered observer list.
- %node . $nodeType
-
次に挙げる数で表現される, %node の型を返す: ◎ Returns the type of node, represented by a number from the following list:
- $Node . $ELEMENT_NODE `(1)^i
- %node は`要素$である。 ◎ node is an element.
- $Node . $TEXT_NODE `(3)^i
- %node は $Text `~node$である。 ◎ node is a Text node.
- $Node . $CDATA_SECTION_NODE `(4)^i
- %node は $CDATASection `~node$である。 ◎ node is a CDATASection node.
- $Node . $PROCESSING_INSTRUCTION_NODE `(7)^i
- %node は $ProcessingInstruction `~node$である。 ◎ node is a ProcessingInstruction node.
- $Node . $COMMENT_NODE `(8)^i
- %node は $Comment `~node$である。 ◎ node is a Comment node.
- $Node . $DOCUMENT_NODE `(9)^i
- %node は`文書$である。 ◎ node is a document.
- $Node . $DOCUMENT_TYPE_NODE `(10)^i
- %node は`~doctype$である。 ◎ node is a doctype.
- $Node . $DOCUMENT_FRAGMENT_NODE `(11)^i
- %node は`文書片$である。 ◎ node is a DocumentFragment node.
- %node . $nodeName
-
%node に応じて,次の文字列を返す: ◎ Returns a string appropriate for the type of node, as follows:
- $Element
- その`~HTML大文字~化~有修飾~名$ ◎ Its HTML-uppercased qualified name.
- $Attr
- その`有修飾~名$a ◎ Its qualified name.
- $Text
- `#text^l ◎ "#text".
- $CDATASection
- `#cdata-section^l ◎ "#cdata-section".
- $ProcessingInstruction
- その $target ◎ Its target.
- $Comment
- `#comment^l ◎ "#comment".
- $Document
- `#document^l ◎ "#document".
- $DocumentType
- その`名前$dT ◎ Its name.
- $DocumentFragment
- `#document-fragment^l ◎ "#document-fragment".
@nodeType 取得子~手続きは、コレに応じて,次に与える値を返す(括弧内は数-値): ◎ The nodeType attribute’s getter, when invoked, must return the first matching statement, switching on this:
- $Element
- @ELEMENT_NODE (1)
- $Attr
- @ATTRIBUTE_NODE (2)
- $Text
- @TEXT_NODE (3)
- $CDATASection
- @CDATA_SECTION_NODE (4)
- $ProcessingInstruction
- @PROCESSING_INSTRUCTION_NODE (7)
- $Comment
- @COMMENT_NODE (8)
- $Document
- @DOCUMENT_NODE (9)
- $DocumentType
- @DOCUMENT_TYPE_NODE (10)
- $DocumentFragment
- @DOCUMENT_FRAGMENT_NODE (11)
@nodeName 取得子~手続きは、コレに応じて,次に与える値を返す: ◎ The nodeName attribute’s getter, when invoked, must return the first matching statement, switching on this:
- $Element
- コレの`~HTML大文字~化~有修飾~名$ ◎ Its HTML-uppercased qualified name.
- $Attr
- コレの`有修飾~名$a ◎ Its qualified name.
- $Text
- `#text^l ◎ "#text".
- $CDATASection
- `#cdata-section^l ◎ "#cdata-section".
- $ProcessingInstruction
- コレの`~target$pI ◎ Its target.
- $Comment
- `#comment^l ◎ "#comment".
- $Document
- `#document^l ◎ "#document".
- $DocumentType
- コレの`名前$dT ◎ Its name.
- $DocumentFragment
- `#document-fragment^l ◎ "#document-fragment".
- %node . $baseURI
- %node の`~node文書$の`文書~基底~URL$を返す。 ◎ Returns node’s node document’s document base URL.
- %node . $isConnected
- [ %node は`接続されて$いるならば ~T / ~ELSE_ ~F ]を返す。 ◎ Returns true if node is connected and false otherwise.
- %node . $ownerDocument
- `~node文書$を返す。 `文書$に対しては ~NULL を返す。 ◎ Returns the node document. Returns null for documents.
- %node . $getRootNode()
- %node の`根$を返す。 ◎ Returns node’s root.
- %node . $getRootNode({ composed:true })
- %node の`~shadowも含む根$を返す。 ◎ Returns node’s shadow-including root.
- %node . $parentNode
- `親$を返す。 ◎ Returns the parent.
- %node . $parentElement
- `親~要素$を返す。 ◎ Returns the parent element.
- %node . $hasChildNodes()
- %node が`子$を持つかどうかを返す。 ◎ Returns whether node has children.
- %node . $childNodes
- `子たち$を返す。 ◎ Returns the children.
- %node . $firstChild
- `最初の子?$を返す。 ◎ Returns the first child.
- %node . $lastChild
- `最後の子?$を返す。 ◎ Returns the last child.
- %node . $previousSibling
- `前-同胞?$を返す。 ◎ Returns the previous sibling.
- %node . $nextSibling
- `次-同胞?$を返す。 ◎ Returns the next sibling.
@ownerDocument 取得子~手続きは ⇒ ~RET [ コレは`文書$である ならば ~NULL / ~ELSE_ コレの`~node文書$ ] ◎ The ownerDocument attribute’s getter must return null, if this is a document, and this’s node document otherwise.
注記: `文書$の`~node文書$は,`文書$ 自身である。 すべての`~node$は、どの時点であれ,`~node文書$を持つ。 ◎ The node document of a document is that document itself. All nodes have a node document at all times.
@parentNode 取得子~手続きは ⇒ ~RET コレの`親$ ◎ The parentNode attribute’s getter must return this’s parent.
注記: $Attr `~node$には親はない。 ◎ An Attr node has no parent.
@previousSibling 取得子~手続きは ⇒ ~RET コレの`前-同胞?$ ◎ The previousSibling attribute’s getter must return this’s previous sibling.
注記: $Attr `~node$には`同胞$はない。 ◎ An Attr node has no siblings.
$nodeValue 設定子~手続きは: ◎ The nodeValue attribute must, on setting,\
- %値 ~LET [ 所与の値 ~NEQ ~NULL ならば それ / ~ELSE_ 空~文字列 ] ◎ if the new value is null, act as if it was the empty string instead, and then\
-
コレに応じて: ◎ do as described below, depending on this:
- $Attr
- `既存の属性o値を設定する$( コレ, %値 ) ◎ Set an existing attribute value with this and new value.
- `文字~data~node$ ◎ Text ProcessingInstruction Comment
- コレの`~dataを置換する$( 0, コレの`長さ$, %値 ) ◎ Replace data with node this, offset 0, count this’s length, and data new value.
- 他の~node ◎ Any other node
- 何もしない ◎ Do nothing.
`~node$ %親 の `全~内容を文字列に置換する@ ときは、所与の ( 文字列 %文字列 ) に対し,次を走らす: ◎ To string replace all with a string string within a node parent, run these steps:
- %~node ~LET ~NULL ◎ Let node be null.
- ~IF[ %文字列 ~NEQ 空~文字列 ] ⇒ %~node ~SET `新たな~Text~node$( %文字列, %親 の`~node文書$ ) ◎ If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document.
- %親 の`全~内容を~nodeで置換する$( %~node ) ◎ Replace all with node within parent.
$textContent 設定子~手続きは: ◎ The textContent attribute’s setter must,\
- %値 ~LET [ 所与の値 ~NEQ ~NULL ならば それ / ~ELSE_ 空~文字列 ] ◎ if the given value is null, act as if it was the empty string instead, and then\
-
コレに応じて: ◎ do as described below, switching on this:
- $DocumentFragment
- $Element
- コレの`全~内容を文字列に置換する$( 所与の値 ) ◎ String replace all with the given value within this.
- $Attr
- `既存の属性o値を設定する$( コレ, 所与の値 ) ◎ Set an existing attribute value with this and new value.
- `文字~data~node$ ◎ Text ProcessingInstruction Comment
- コレの`~dataを置換する$( 0, コレの`長さ$, %値 ) ◎ Replace data with node this, offset 0, count this’s length, and data the given value.
- $Document
- $DocumentType
- 何もしない ◎ Do nothing.
- %node . $normalize()
- %node に含まれている`狭義の~Text~node$のうち[ `長さ$ ~EQ 0 ]のものは除去し、`連続的な狭義の~Text~node列$に対しては,その最初の`~node$に~~後続の`~data$を連結してひとまとめにする。 ◎ Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
- 【 この記述は、 “除去-” と “連結-” の順序に関し,微妙に正確でない — 実際の~algoでは、空 ^Text ~nodeのうち,[ 最初の~node %N が空でないような`連続的な狭義の~Text~node列$ ]に含まれるものは、後続の空 ^Text ~nodeより先に %N に連結される(その結果として,除去されるが)。 】
@normalize() ~method~手続きは: ◎ The normalize() method, when invoked, must run these steps\
-
コレの`子孫$である ~EACH( `狭義の~Text~node$ %node ) に対し: ◎ for each descendant exclusive Text node node of this:
【 ~tree順序で。 加えて,~~厳密に言えば、このループの中で~treeから除去される ^Text ~nodeは反復対象から除外する必要もある。 】
- %長さ ~LET %node の`長さ$ ◎ Let length be node’s length.
- %長さ ~EQ 0 ⇒# `~nodeを除去する$( %node ); ~CONTINUE ◎ If length is zero, then remove node and continue with the next exclusive Text node, if any.
- %除去対象 ~LET %node を含む`連続的な狭義の~Text~node列$から %node 自身(常に先頭になる)は除外した結果の~list ◎ ↓
- %data ~LET 次を`連結-$した結果 ⇒ %除去対象 内のすべての~nodeの`~data$ ◎ Let data be the concatenation of the data of node’s contiguous exclusive Text nodes (excluding itself), in tree order.
- %node の`~dataを置換する$( %長さ, 0, %data ) ◎ Replace data with node node, offset length, count 0, and data data.
-
%除去対象 内の ~EACH( %text ) に対し,順に: ◎ Let currentNode be node’s next sibling. ◎ While currentNode is an exclusive Text node:
-
~EACH( `~live範囲o$ %R ) に対し: ◎ ↓
- ~IF[ %範囲o の`始端~node$ ~EQ %text ] ⇒# %範囲o の`始端~offset$ ~INCBY %長さ; %範囲o の`始端~node$ ~SET %node ◎ For each live range whose start node is currentNode, add length to its start offset and set its start node to node.
- ~IF[ %範囲o の`終端~node$ ~EQ %text ] ⇒# %範囲o の`終端~offset$ ~INCBY %長さ; %範囲o の`終端~node$ ~SET %node ◎ For each live range whose end node is currentNode, add length to its end offset and set its end node to node.
- ~IF[ %範囲o の`始端~node$ ~EQ %text の`親$ ]~AND[ %範囲o の`始端~offset$ ~EQ %text の`~index$ ] ⇒# %範囲o の`始端~node$ ~SET %node; %範囲o の`始端~offset$ ~SET %長さ ◎ For each live range whose start node is currentNode’s parent and start offset is currentNode’s index, set its start node to node and its start offset to length.
- ~IF[ %範囲o の`終端~node$ ~EQ %text の`親$ ]~AND[ %範囲o の`終端~offset$ ~EQ %text の`~index$ ] ⇒# %範囲o の`終端~node$ ~SET %node; %範囲o の`終端~offset$ ~SET %長さ ◎ For each live range whose end node is currentNode’s parent and end offset is currentNode’s index, set its end node to node and its end offset to length.
- %長さ ~INCBY %text の`長さ$ ◎ Add currentNode’s length to length. ◎ Set currentNode to its next sibling.
-
- %除去対象 内の ~EACH( %text ) に対し,順に ⇒ `~nodeを除去する$( %text ) ◎ Remove node’s contiguous exclusive Text nodes (excluding itself), in tree order.
- %node . $cloneNode([deep = false])
- %node の複製を返す。 %deep が~T の場合、複製には %node の`子孫$も含められる。 ◎ Returns a copy of node. If deep is true, the copy also includes the node’s descendants.
- %node . $isEqualNode(otherNode)
- %node と %otherNode が同じ~propを持つかどうかを返す。 ◎ Returns whether node and otherNode have the same properties.
`適用-可能な仕様$は、すべてまたは一部の`~node$用に `~clone時の手続き@ を定義してもヨイ。 この~algoは、`~nodeを~cloneする$ ~algo内から, ( %複製, %node, %文書, %子も~cloneする~flag ~IN { `子も~cloneする^i, ε }(省略時は ε ) ) を渡して呼出される。 ◎ Specifications may define cloning steps for all or some nodes. The algorithm is passed copy, node, document, and an optional clone children flag, as indicated in the clone algorithm.
注記: ~HTMLは `script$e / `input$e 要素~用に`~clone時の手続き$を定義する。 ~SVGもその `script^e 要素~用にも同様にされるべきだが、現時点では,呼び出すことはない。 ◎ HTML defines cloning steps for script and input elements. SVG ought to do the same for its script elements, but does not call this out at the moment.
【 同じ~node用に,そのような手続きが(例えば,複数の仕様にて)複数~定義された場合、それらを走らす順序も有意になり得るが,言及されていないので想定されていない(または有意にならない)と見受けられる。 他の “〜時の手続き” (例: `挿入-時の手続き$)も同様。 】
`~nodeを~cloneする@ ときは、所与の ( %node, `文書$ %文書 (省略時は ε ), %子も~cloneする~flag ~IN { `子も~cloneする^i, ε }(省略時は ε ) ) に対し,次を走らす: ◎ To clone a node, with an optional document and clone children flag, run these steps:
- ~IF[ %文書 ~EQ ε ] ⇒ %文書 ~LET %node の`~node文書$ ◎ If document is not given, let document be node’s node document.
-
~IF[ %node は`要素$である ]: ◎ If node is an element, then:
- %複製 ~LET `要素を作成する$( %文書, %node の`局所~名$, %node の`~ns$, %node の`~ns接頭辞$, %node の`~is0値$ ) ◎ Let copy be the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset.
- %node の`属性o~list$内の ~EACH( %属性o ) に対し ⇒ `属性oを付加する$( `~nodeを~cloneする$( %属性o ), %複製 ) ◎ For each attribute in node’s attribute list: • Let copyAttribute be a clone of attribute. • Append copyAttribute to copy.
-
~ELSE: ◎ Otherwise,\
- %複製 ~LET %node と同じ~interfaceを実装する新たな`~node$ ◎ let copy be a node that implements the same interfaces as node, and\
-
%node に応じて, %複製 を次に従って設定する: ◎ fulfills these additional requirements, switching on node:
- $Document
- %複製 の[ `符号化法$doc, `内容~型$doc, `~URL$doc, `生成元$doc, `種別$doc, `~mode$doc ] ~SET %node のそれら ◎ Set copy’s encoding, content type, URL, origin, type, and mode, to those of node.
- $DocumentType
- %複製 の[ `名前$dT, `~publicID$dT, `~systemID$dT ] ~SET %node のそれら ◎ Set copy’s name, public ID, and system ID, to those of node.
- $Attr
- %複製 の[ `~ns$a, `~ns接頭辞$a, `局所~名$a, `値$a ] ~SET %node のそれら ◎ Set copy’s namespace, namespace prefix, local name, and value, to those of node.
- $Text
- $Comment
- %複製 の`~data$ ~SET %node のそれ ◎ Set copy’s data, to that of node.
- $ProcessingInstruction
- %複製 の[ `~target$pI, `~data$ ] ~SET %node のそれら ◎ Set copy’s target and data to those of node.
- 他の~node ◎ Any other node
- —
- 【 すなわち, $DocumentFragment ( $ShadowRoot )が該当するが、[ これらに対しこの~algoが呼出されることはない ]ことを意味すると思われる。 】
- ~IF[ %複製 は`文書$である ] ⇒ %文書 ~SET %複製 ◎ ↓
- %複製 の`~node文書$ ~SET %文書 ◎ Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise.
- ~IF[ 他の`適用-可能な仕様$において %node 用に定義されている`~clone時の手続き$がある ] ⇒ その手続きに ( %複製, %node, %文書, %子も~cloneする~flag ) を渡して走らす ◎ Run any cloning steps defined for node in other applicable specifications and pass copy, node, document and the clone children flag if set, as parameters.
- ~IF[ %子も~cloneする~flag ~NEQ ε ] ⇒ %node の`子たち$を成す ~EACH( %子 ) に対し ⇒ %複製 に次を付加する ⇒ `~nodeを~cloneする$( %子, %文書, `子も~cloneする^i ) ◎ If the clone children flag is set, clone all the children of node and append them to copy, with document as specified and the clone children flag being set.
- ~RET %複製 ◎ Return copy.
@cloneNode(deep) ~method~手続きは: ◎ The cloneNode(deep) method, when invoked, must run these steps:
- ~IF[ コレは`~shadow根$である ] ⇒ ~THROW `NotSupportedError$E ◎ If this is a shadow root, then throw a "NotSupportedError" DOMException.
- ~RET `~nodeを~cloneする$( コレ, ε, [ %deep ~EQ ~T ならば `子も~cloneする^i / ~ELSE_ ε ] ) ◎ Return a clone of this, with the clone children flag set if deep is true.
2 つの`~node$ %A, %B は、次に挙げるすべての条件を満たすならば, `同等@ であるとされる。 ◎ A node A equals a node B if all of the following conditions are true:
- %A と %B の $nodeType 属性~値は一致する。 ◎ A and B’s nodeType attribute value is identical.
-
%A に応じて,次も同等: ◎ The following are also equal, depending on A:
- $DocumentType
- `名前$dT, `~publicID$dT, `~systemID$dT ◎ Its name, public ID, and system ID.
- $Element
- `~ns$, `~ns接頭辞$, `局所~名$, `属性o~list$の`~size$ ◎ Its namespace, namespace prefix, local name, and its attribute list’s size.
- $Attr
- `~ns$a, `局所~名$a, `値$a ◎ Its namespace, local name, and value.
- $ProcessingInstruction
- `~target$pI, `~data$ ◎ Its target and data.
- $Text
- $Comment
- `~data$ ◎ Its data.
- 他の~node 【$Document, $DocumentFragment ( $ShadowRoot )】 ◎ Any other node
- — 【原文には “—” としか記されていないが、 “この項に関しては無条件” を意味するようだ。】
- %A が`要素$である場合に限り ⇒ %A の`属性o~list$内のどの`属性o$ %属性 に対しても ⇒ %B の`属性o~list$内に[ %属性 に`同等$である`属性o$ ]が在る ◎ If A is an element, each attribute in its attribute list has an attribute that equals an attribute in B’s attribute list.
- %A と %B は同じ個数の`子$を持つ ◎ A and B have the same number of children.
- %A のどの`子$も,同じ`~index$に位置する %B の`子$に`同等$である ◎ Each child of A equals the child of B at the identical index.
- %node . $compareDocumentPosition(other)
-
%node に相対的な %other の位置を指示する~bitmaskを返す。 それを成す各~bitは、対応する条件が満たされる場合には, “1” に設定される: ◎ Returns a bitmask indicating the position of other relative to node. These are the bits that can be set:
- $Node . $DOCUMENT_POSITION_DISCONNECTED `(1)^i
- %node と %other は同じ`~tree$に属さない。 ◎ Set when node and other are not in the same tree.
- $Node . $DOCUMENT_POSITION_PRECEDING `(2)^i
- %other は %node に`先行-$する。 ◎ Set when other is preceding node.
- $Node . $DOCUMENT_POSITION_FOLLOWING `(4)^i
- %other は %node に`後続-$する。 ◎ Set when other is following node.
- $Node . $DOCUMENT_POSITION_CONTAINS `(8)^i
- %other は %node の`先祖$である。 ◎ Set when other is an ancestor of node.
- $Node . $DOCUMENT_POSITION_CONTAINED_BY `(16)^i
- %other は %node の`子孫$である。 ◎ Set when other is a descendant of node.
- %node . $contains(other)
- %other が %node の`広義子孫$ならば ~T, 他の場合は~F を返す。 ◎ Returns true if other is an inclusive descendant of node, and false otherwise.
次に挙げるものは $compareDocumentPosition() が~bitmaskとして返す定数である(括弧内は数-値): ◎ These are the constants compareDocumentPosition() returns as mask:
- @DOCUMENT_POSITION_DISCONNECTED (1)
- @DOCUMENT_POSITION_PRECEDING (2)
- @DOCUMENT_POSITION_FOLLOWING (4)
- @DOCUMENT_POSITION_CONTAINS (8)
- @DOCUMENT_POSITION_CONTAINED_BY (16 ~EQ 0x10)
- @DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC (32 ~EQ 0x20)
@compareDocumentPosition(other) ~method~手続きは: ◎ The compareDocumentPosition(other) method, when invoked, must run these steps:
- ~IF[ コレ ~EQ %other ] ⇒ ~RET 0 ◎ If this is other, then return zero.
- ( %他~node, %自~node ) ~LET ( %other, コレ ) ◎ Let node1 be other and node2 be this.
- ( %他~属性o, %自~属性o ) ~LET ( ~NULL, ~NULL ) ◎ Let attr1 and attr2 be null.
- ~IF[ %他~node は`属性o$である ] ⇒# %他~属性o ~SET %他~node; %他~node ~SET %他~属性o が`属する要素$ ◎ If node1 is an attribute, then set attr1 to node1 and node1 to attr1’s element.
-
~IF[ %自~node は`属性o$である ]: ◎ If node2 is an attribute, then:
- %自~属性o ~SET %自~node ◎ ↓
- %自~node ~SET %自~属性o が`属する要素$ ◎ Set attr2 to node2 and node2 to attr2’s element.
-
~IF[ %他~属性o ~NEQ ~NULL ]~AND[ %自~属性o ~NEQ ~NULL ]~AND[ %自~node ~EQ %他~node ]: ◎ If attr1 and node1 are non-null, and node2 is node1, then:
-
%自~node の`属性o~list$内の ~EACH( %属性o ) に対し: ◎ For each attr in node2’s attribute list:
- ~IF[ ( %属性o, %他~属性o ) は`同等$である ] ⇒ ~RET $DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ~PLUS $DOCUMENT_POSITION_PRECEDING ◎ If attr equals attr1, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_PRECEDING.
- ~IF[ ( %属性o, %自~属性o ) は`同等$である ] ⇒ ~RET $DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ~PLUS $DOCUMENT_POSITION_FOLLOWING ◎ If attr equals attr2, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_FOLLOWING.
-
-
~IF[ %他~node ~EQ ~NULL ]~OR[ %自~node ~EQ ~NULL ]~OR[ %他~node の`根$ ~NEQ %自~node の`根$ ] ⇒ ~RET [ $DOCUMENT_POSITION_DISCONNECTED ~PLUS $DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ~PLUS [ $DOCUMENT_POSITION_PRECEDING または $DOCUMENT_POSITION_FOLLOWING (ただし,いずれが~~選択されるかは一貫するものとする)] ] ◎ If node1 or node2 is null, or node1’s root is not node2’s root, then return the result of adding DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING, with the constraint that this is to be consistent, together.
注記: $DOCUMENT_POSITION_PRECEDING, $DOCUMENT_POSITION_FOLLOWING のどちらを返すかは,概して~pointer比較を介して実装される。 ~JS実装においては `Math.random()^c 値を利用できる。 【理想的には、各~node~treeどうしの順序も循環しないように一貫するべきであろう。】 ◎ Whether to return DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING is typically implemented via pointer comparison. In JavaScript implementations a cached Math.random() value can be used.
- ~IF[[ %他~node は %自~node の`先祖$である ]~AND[ %他~属性o ~EQ ~NULL ]]~OR[[ %他~node ~EQ %自~node ]~AND[ %自~属性o ~NEQ ~NULL ]] ⇒ ~RET $DOCUMENT_POSITION_CONTAINS ~PLUS $DOCUMENT_POSITION_PRECEDING ◎ If node1 is an ancestor of node2 and attr1 is null, or node1 is node2 and attr2 is non-null, then return the result of adding DOCUMENT_POSITION_CONTAINS to DOCUMENT_POSITION_PRECEDING.
- ~IF[[ %他~node は %自~node の`子孫$である ]~AND[ %自~属性o ~EQ ~NULL ]]~OR[[ %他~node ~EQ %自~node ]~AND[ %他~属性o ~NEQ ~NULL ]] ⇒ ~RET $DOCUMENT_POSITION_CONTAINED_BY ~PLUS $DOCUMENT_POSITION_FOLLOWING ◎ If node1 is a descendant of node2 and attr2 is null, or node1 is node2 and attr1 is non-null, then return the result of adding DOCUMENT_POSITION_CONTAINED_BY to DOCUMENT_POSITION_FOLLOWING.
-
~IF[ %他~node は %自~node に`先行-$する ] ⇒ ~RET $DOCUMENT_POSITION_PRECEDING ◎ If node1 is preceding node2, then return DOCUMENT_POSITION_PRECEDING.
注記: `属性o$は`~tree$には`関与-$しないが、この~algoに因り、`属性o$は,それが`属する要素$の`子$に`先行-$するものとされることになる。 ◎ Due to the way attributes are handled in this algorithm this results in a node’s attributes counting as preceding that node’s children, despite attributes not participating in a tree.
- ~RET $DOCUMENT_POSITION_FOLLOWING ◎ Return DOCUMENT_POSITION_FOLLOWING.
%要素 用の `~ns接頭辞を~locateする@ ときは、所与の ( %~ns ) に対し,次を走らす: ◎ To locate a namespace prefix for an element using namespace, run these steps:
- ~IF[ %要素 の`~ns$ ~EQ %~ns ]~AND[ %要素 の`~ns接頭辞$ ~NEQ ~NULL ] ⇒ ~RET %要素 の`~ns接頭辞$ ◎ If element’s namespace is namespace and its namespace prefix is non-null, then return its namespace prefix.
- %属性o ~LET %要素 の`属性o~list$内に在る`属性o$のうち,次を満たす`最初のもの?$ ⇒ [ `~ns接頭辞$a ~EQ `xmlns^l ]~AND[ `値$a ~EQ %~ns ] ◎ If element has an attribute whose namespace prefix is "xmlns" and value is namespace, then return element’s first such attribute’s local name.
- ~IF[ %属性o ~NEQ ~NULL ] ⇒ ~RET %属性 の`局所~名$a ◎ ↑
- %親 ~SET %要素 の`親~要素$ ◎ ↓
- ~IF[ %親 ~NEQ ~NULL ] ⇒ ~RET %親 用の`~ns接頭辞を~locateする$( %~ns ) ◎ If element’s parent element is not null, then return the result of running locate a namespace prefix on that element using namespace.
- ~RET ~NULL ◎ Return null.
%node 用の `~nsを~locateする@ ときは、所与の ( %接頭辞 ) に対し,次を走らす: ◎ To locate a namespace for a node using prefix,\
- %要素 ~LET ~NULL ◎ ↓
-
%node に応じて: ◎ switch on node:
- $Element
-
- ~IF[ %node の`~ns$ ~NEQ ~NULL ]~AND[ %node の`~ns接頭辞$ ~EQ %接頭辞 ] ⇒ ~RET その`~ns$ ◎ If its namespace is non-null and its namespace prefix is prefix, then return namespace.
-
%属性o ~LET %要素 の`属性o~list$内に在る`属性o$のうち[ %接頭辞 に応じて,次に与える条件 ]を満たす`最初のもの?$:
- %接頭辞 ~NEQ ~NULL の場合 ⇒ [ `~ns$a ~EQ `~XMLNS~ns$ ]~AND[ `~ns接頭辞$a ~EQ `xmlns^l ]~AND[ `局所~名$a ~EQ %接頭辞 ]
- %接頭辞 ~EQ ~NULL の場合 ⇒ [ `~ns$a ~EQ `~XMLNS~ns$ ]~AND[ `~ns接頭辞$a ~EQ ~NULL ]~AND[ `局所~名$a ~EQ `xmlns^l ]
- ~IF[ %属性o ~NEQ ~NULL ] ⇒ ~RET [ %属性o の`値$a ~NEQ 空~文字列 ならばそれ / ~ELSE_ ~NULL ] ◎ then return its value if it is not the empty string, and null otherwise.
- %要素 ~SET %node の`親~要素$ ◎ If its parent element is null, then return null. ◎ Return the result of running locate a namespace on its parent element using prefix.
- $Document
- %要素 ~SET %node の`文書~要素$ ◎ If its document element is null, then return null. ◎ Return the result of running locate a namespace on its document element using prefix.
- $DocumentType
- $DocumentFragment
- ~RET ~NULL ◎ Return null.
- $Attr
- %要素 ~SET %node が`属する要素$ ◎ If its element is null, then return null. ◎ Return the result of running locate a namespace on its element using prefix.
- 他の~node(`文字~data~node$) ◎ Any other node
- %要素 ~SET %node の`親~要素$ ◎ If its parent element is null, then return null. ◎ Return the result of running locate a namespace on its parent element using prefix.
- ~IF[ %要素 ~NEQ ~NULL ] ⇒ ~RET %要素 用の`~nsを~locateする$( %接頭辞 ) ◎ ↑
- ~RET ~NULL ◎ ↑
@lookupPrefix(namespace) ~method~手続きは: ◎ The lookupPrefix(namespace) method, when invoked, must run these steps:
- ~IF[ %namespace ~IN { ~NULL, 空~文字列 } ] ⇒ ~RET ~NULL ◎ If namespace is null or the empty string, then return null.
-
%要素 ~LET コレに応じて,次で与えられる[ 要素, または ~NULL ]: ◎ Switch on this:
- $Element
- コレ ◎ Return the result of locating a namespace prefix for it using namespace.
- $Document
- コレの`文書~要素$ ◎ Return the result of locating a namespace prefix for its document element, if its document element is non-null, and null otherwise.
- $DocumentType
- $DocumentFragment
- ~NULL ◎ Return null.
- $Attr
- コレが`属する要素$ ◎ Return the result of locating a namespace prefix for its element, if its element is non-null, and null otherwise.
- 他の~node(`文字~data~node$) ◎ Any other node
- コレの`親~要素$ ◎ Return the result of locating a namespace prefix for its parent element, if its parent element is non-null, and null otherwise.
- ~IF [ %要素 ~NEQ ~NULL ] ⇒ ~RET %要素 用の`~ns接頭辞を~locateする$( %namespace ) ◎ ↑
- ~RET ~NULL ◎ ↑
@lookupNamespaceURI(prefix) ~method~手続きは: ◎ The lookupNamespaceURI(prefix) method, when invoked, must run these steps:
- ~IF[ %prefix ~EQ 空~文字列 ] ⇒ %prefix ~SET ~NULL ◎ If prefix is the empty string, then set it to null.
- ~RET コレ用の`~nsを~locateする$( %prefix ) ◎ Return the result of running locate a namespace for this using prefix.
@isDefaultNamespace(namespace) ~method~手続きは: ◎ The isDefaultNamespace(namespace) method, when invoked, must run these steps:
- ~IF[ %namespace ~EQ 空~文字列 ] ⇒ %namespace ~SET ~NULL ◎ If namespace is the empty string, then set it to null.
- %既定~ns ~LET コレ用の`~nsを~locateする$( ~NULL ) ◎ Let defaultNamespace be the result of running locate a namespace for this using null.
- ~RET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ %既定~ns ~EQ %namespace ◎ Return true if defaultNamespace is the same as namespace, and false otherwise.
@insertBefore(node, child) ~method~手続きは ⇒ ~RET コレの中で`~nodeを子の前に前挿入する$( %node, %child ) ◎ The insertBefore(node, child) method, when invoked, must return the result of pre-inserting node into this before child.
【 ~HTMLの `br^e のような~void要素であっても(あるいは `script^e 要素であっても)、子~nodeを挿入でき,~treeの一部を成すことになる — より一般には、文書~言語の内容~modelでは許容されなくても,`~node~tree$の拘束に反しない限り挿入できる。 ~treeを改変する他の~method(次の $appendChild() など)も同様。 】
`~node$ %根 用の[ %有修飾~名 を `有修飾~名に持つ要素の~list@ ]は、次のように設定された $HTMLCollection を返す: ◎ The list of elements with qualified name qualifiedName for a node root is the HTMLCollection returned by the following algorithm:
【!*局所~名 = * の場合でも、根は除外される https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName】- `根$cL ~SET %根 ◎ ↓
-
`~filter$cLは[ %根 の`子孫$である`要素$ %要素 のうち,次のいずれかが満たされるもの ]に合致する: ◎ ↓
- %有修飾~名 ~EQ `*^l (~U002A) (この場合、 %要素 は無条件に合致することになる) ◎ If qualifiedName is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches only descendant elements.
-
[ %根 の`~node文書$は`~HTML文書$である ]~AND[ 次のいずれかが満たされる ]: ◎ Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements:
- [ `~ns$ ~EQ `~HTML~ns$ ]~AND[ %要素 の`有修飾~名$ ~EQ `~ASCII小文字~化する$( %有修飾~名 ) ] ◎ Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase.
- [ `~ns$ ~NEQ `~HTML~ns$ ]~AND[ %要素 の`有修飾~名$ ~EQ %有修飾~名 ] ◎ Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.
- %要素 の`有修飾~名$ ~EQ %有修飾~名 ◎ Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose qualified name is qualifiedName.
以前の~callと同じ引数で呼出されたときは、 %根 の`~node文書$の`種別$docが変化していない限り,そのときに返したものと同じ $HTMLCollection ~objを返してもヨイ。 ◎ When invoked with the same argument, and as long as root’s node document’s type has not changed, the same HTMLCollection object may be returned as returned by an earlier call.
`~node$ %根 用の[ ( %~ns, %局所~名 ) を `( ~ns, 局所~名 ) に持つ要素の~list@ ]は、次のように設定された $HTMLCollection を返す: ◎ The list of elements with namespace namespace and local name localName for a node root is the HTMLCollection returned by the following algorithm:
- `根$cL ~SET %根 ◎ ↓
-
`~filter$cLは[ %根 の`子孫$である`要素$ %要素 のうち,次の結果 ~EQ ~T になるもの ]に合致する:
- 【!cp-normalize-ns】 ~IF[ %~ns ~EQ 空~文字列 ] ⇒ %~ns ~SET ~NULL
- ~RET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ [ %~ns ~IN { `*^l (~U002A), %要素 の`~ns$ } ]~AND[ %局所~名 ~IN { `*^l (~U002A), %要素 の`局所~名$ } ]
( %~ns ~EQ %局所~名 ~EQ `*^l の場合、 %要素 は無条件に合致することになる)
◎ If namespace is the empty string, set it to null. ◎ If both namespace and localName are "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements. ◎ Otherwise, if namespace is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose local name is localName. ◎ Otherwise, if localName is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace. ◎ Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace and local name is localName.
以前の~callと同じ引数で呼出されたときは,そのときに返したものと同じ $HTMLCollection ~objを返してもヨイ。 ◎ When invoked with the same argument, the same HTMLCollection object may be returned as returned by an earlier call.
`~node$ %根 用の[ %classNames を `~classesに含む要素の~list@ ]とは、次の~algoが返す $HTMLCollection である: ◎ The list of elements with class names classNames for a node root is the HTMLCollection returned by the following algorithm:
- %~classes ~LET %classNames を`有順序~集合 構文解析器$にかけた結果 ◎ Let classes be the result of running the ordered set parser on classNames.
- ~IF[ %~classes は空である ] ⇒ ~RET 空な $HTMLCollection ◎ If classes is the empty set, return an empty HTMLCollection.
-
~RET 次のように設定された $HTMLCollection `~collection$ ⇒# `根$cL ~SET %根, `~filter$cLは %根 の`子孫$である`要素$のうち次を満たすものに合致する ⇒ その`~classes$は %~classes を成す どの~tokenも含む ◎ Return a HTMLCollection rooted at root, whose filter matches descendant elements that have all their classes in classes.
`~classes$と %~classes の中の各~tokenの比較は、[ %根 の`~node文書$の`~mode$docが `quirks^l ならば `~ASCII大小無視$ / ~ELSE_ `一致する$かどうか ]で行うモノトスル。 ◎ The comparisons for the classes must be done in an ASCII case-insensitive manner if root’s node document’s mode is "quirks", and in an identical to manner otherwise.
4.5. ^@Document ~interface
!! [`Exposed$=Window] interface @Document : $Node { `Document$mc(); [`SameObject$] ~RA $DOMImplementation $implementation; ~RA $USVString $URL; ~RA $USVString $documentURI; ~RA $DOMString $compatMode; ~RA $DOMString $characterSet; ~RA $DOMString $charset; // $characterSet の旧来の別名 ~RA $DOMString $inputEncoding; // ~RA $DOMString $contentType; ~RA $DocumentType? $doctype; ~RA $Element? $documentElement; $HTMLCollection $getElementsByTagName($DOMString %qualifiedName); $HTMLCollection $getElementsByTagNameNS($DOMString? %namespace, $DOMString %localName); $HTMLCollection $getElementsByClassName($DOMString %classNames); [`CEReactions$, `NewObject$] $Element $createElement($DOMString %localName, optional ($DOMString or $ElementCreationOptions) %options = {}); [`CEReactions$, `NewObject$] $Element $createElementNS($DOMString? %namespace, $DOMString %qualifiedName, optional ($DOMString or $ElementCreationOptions) %options = {}); [`NewObject$] $DocumentFragment $createDocumentFragment(); [`NewObject$] $Text $createTextNode($DOMString %data); [`NewObject$] $CDATASection $createCDATASection($DOMString %data); [`NewObject$] $Comment $createComment($DOMString %data); [`NewObject$] $ProcessingInstruction $createProcessingInstruction($DOMString %target, $DOMString %data); [`CEReactions$, `NewObject$] $Node $importNode($Node %node, optional $boolean %deep = false); [`CEReactions$] $Node $adoptNode($Node %node); [`NewObject$] $Attr $createAttribute($DOMString %localName); [`NewObject$] $Attr $createAttributeNS($DOMString? %namespace, $DOMString %qualifiedName); [`NewObject$] $Event $createEvent($DOMString %interface); // [`NewObject$] $Range $createRange(); // $NodeFilter.$NodeFilter.SHOW_ALL = 0xFFFFFFFF [`NewObject$] $NodeIterator $createNodeIterator($Node %root, optional `unsigned long$ %whatToShow = 0xFFFFFFFF, optional $NodeFilter? %filter = null); [`NewObject$] $TreeWalker $createTreeWalker($Node %root, optional `unsigned long$ %whatToShow = 0xFFFFFFFF, optional $NodeFilter? %filter = null); }; [`Exposed$=Window] interface @XMLDocument : $Document {}; dictionary @@ElementCreationOptions { $DOMString @is; }; !$@Document `~node$は、単に `文書@ ( `document^en )とも称される。 ◎ Document nodes are simply known as documents.
各 `文書$には、次に挙げるものが結付けられる — 他が言明されない限り,括弧内に示される値をとるとする:
- `符号化法@doc( `utf-8$ )
- `符号化法$
- `内容~型@doc( `application/xml^l )
- 文字列
- `~URL@doc( `about:blank^l †)
- `~URL$
- 【† 厳密には、 `about:blank^l が表現する `~URL$ (文字列ではないので)。 】
- `生成元@doc( `不透明な生成元$ )
- `生成元$
- `種別@doc( `xml^l )
- 次のいずれか ⇒# `xml^l, `html^l
- `~mode@doc( `no-quirks^l )
- 次のいずれか ⇒# `no-quirks^l, `quirks^l, `limited-quirks^l
`ENCODING$r `URL$r `HTML$r
◎ Each document has an associated encoding (an encoding), content type (a string), URL (a URL), origin (an origin), type ("xml" or "html"), and mode ("no-quirks", "quirks", or "limited-quirks"). [ENCODING] [URL] [HTML] ◎ Unless stated otherwise, a document’s encoding is the utf-8 encoding, content type is "application/xml", URL is "about:blank", origin is an opaque origin, type is "xml", and its mode is "no-quirks".`文書$は、その`種別$docに応じて:
- `xml^l ならば `~XML文書@ であるとされる。
- `html^l ならば `~HTML文書@ であるとされる。
一部の~APIの挙動は、この 2 種のどちらなのかにより,影響される。
◎ A document is said to be an XML document if its type is "xml", and an HTML document otherwise. Whether a document is an HTML document or an XML document affects the behavior of certain APIs.`文書$は、その`~mode$docに応じて:
- `no-quirks^l ならば `過去互換なし~mode@ 下にあるとされる。
- `quirks^l ならば `過去互換~mode@ 下にあるとされる。
- `limited-quirks^l ならば `制限付き過去互換~mode@ 下にあるとされる。
注記: ~modeが既定の~modeから変更されるのは、`文書$が,新たな`閲覧文脈$(初期の `about:blank^l )から,[ DOCTYPE 文字列の有無, およびその値 ]に基づいて `~HTML構文解析器$を通して作成される場合に限られる。 `HTML$r ◎ The mode is only ever changed from the default for documents created by the HTML parser based on the presence, absence, or value of the DOCTYPE string, and by a new browsing context (initial "about:blank"). [HTML]
注記: `過去互換なし~mode$ は 元々は “標準~mode” と称され, `制限付き過去互換~mode$ は かつては “ほぼ標準~mode” と称されていた。 それらは今や標準により定義されたので(また、それらの元々の名称が~~的外れであることから Ian Hickson が~~否決したので)、改称された。 ◎ No-quirks mode was originally known as "standards mode" and limited-quirks mode was once known as "almost standards mode". They have been renamed because their details are now defined by standards. (And because Ian Hickson vetoed their original names on the basis that they are nonsensical.)
`文書$ %文書 の`親~targetを取得する$ときは、所与の~event %~event に対し:
- ~IF[ %~event の $Event.type 属性~値 ~EQ `load^l ]~OR[ %文書 が`属する閲覧文脈$ ~EQ ~NULL ] ⇒ ~RET ~NULL
- ~RET %文書 に`関連な大域~obj$
- %document = $Document()
- 新たな`文書$を返す。 ◎ Returns a new document.
- %document . $implementation
- %document の $DOMImplementation ~objを返す。 ◎ Returns document’s DOMImplementation object.
- %document . $URL
- %document . $documentURI
- %document の`~URL$doc を返す。 ◎ Returns document’s URL.
- %document . $compatMode
- %document の`~mode$docが[ `quirks^l ならば文字列 `BackCompat^l / ~ELSE_ `CSS1Compat^l ]を返す。 ◎ Returns the string "BackCompat" if document’s mode is "quirks", and "CSS1Compat" otherwise.
- %document . $characterSet
- %document の`符号化法$docを返す。 ◎ Returns document’s encoding.
- %document . $contentType
- %document の`内容~型$docを返す。 ◎ Returns document’s content type.
@Document() 構築子~手続きは ⇒ コレの`生成元$doc ~SET `現在の大域~obj$に`結付けられている文書$の`生成元$doc `HTML$r ◎ The Document() constructor, when invoked, must return a new document whose origin is the origin of current global object’s associated Document. [HTML]
注記: $DOMImplementation.createDocument() と違って、この構築子は $XMLDocument ~objではなく,`文書$( $Document ~obj)を返す。 ◎ Unlike createDocument(), this constructor does not return an XMLDocument object, but a document (Document object).
@URL, @documentURI 取得子~手続きは、いずれも ⇒ ~RET `~URLを直列化する$( コレの`~URL$doc ) ◎ The URL attribute’s getter and documentURI attribute’s getter must return the URL, serialized.
- %document . $doctype
- `~doctype$が[ 在ればそれ / 無ければ~NULL ]を返す。 ◎ Returns the doctype or null if there is none.
- %document . $documentElement
- `文書~要素$を返す。 ◎ Returns the document element.
- %collection = %document . $getElementsByTagName(qualifiedName)
-
引数に応じて,次を満たす`子孫$`要素$すべてからなる $HTMLCollection を返す:
- %qualifiedName ~EQ `*^l の場合: 無条件。
-
他の場合、次のいずれかを満たすもの:
- `有修飾~名$ ~EQ %qualifiedName
- [ `~HTML文書$ 内に在る ]~AND[ `~HTML~ns$に属する ]~AND[ `有修飾~名$は %qualifiedName に~ASCII大小無視で合致する ]
- %collection = %document . $getElementsByTagNameNS(namespace, localName)
-
引数に応じて,次を満たす`子孫$`要素$すべてからなる $HTMLCollection を返す: ◎ ↓
- %namespace, %localName ともに `*^l の場合: 無条件。 ◎ If namespace and localName are "*" returns a HTMLCollection of all descendant elements.
- %namespace のみ `*^l の場合: [ `局所~名$ ~EQ %localName ]なるもの。 ◎ If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName.
- %localName のみ `*^l の場合: [ `~ns$ ~EQ %namespace ]なるもの。 ◎ If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace.
- 他の場合: [ `~ns$ ~EQ %namespace ]~AND[ `局所~名$ ~EQ %localName ]なるもの。 ◎ Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName.
- %collection = %document . $getElementsByClassName(classNames)
- %collection = %element . $Element.getElementsByClassName(classNames)
- ~methodが呼出された~obj(`文書$または`要素$)内の`要素$のうち,[ %classNames で与えられる一連の~class名をすべて持つもの ]からなる $HTMLCollection を返す。 %classNames 引数は一連の~class名の~space区切り~listとして解釈される。 ◎ Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes.
@getElementsByTagName(qualifiedName) ~method~手続きは ⇒ ~RET コレ用の[ %qualifiedName を`有修飾~名に持つ要素の~list$ ] ◎ The getElementsByTagName(qualifiedName) method, when invoked, must return the list of elements with qualified name qualifiedName for this.
注記: したがって,`~HTML文書$においては、 `document.getElementsByTagName("FOO")^c は `~HTML~ns$に属さない `FOO^e 要素と `~HTML~ns$に属する `foo^e 要素に合致し, `~HTML~ns$に属する `FOO^e 要素には合致しないことになる。 ◎ Thus, in an HTML document, document.getElementsByTagName("FOO") will match <FOO> elements that are not in the HTML namespace, and <foo> elements that are in the HTML namespace, but not <FOO> elements that are in the HTML namespace.
@getElementsByClassName(classNames) ~method~手続きは ⇒ ~RET コレ用の[ %classNames を`~classesに含む要素の~list$ ] ◎ The getElementsByClassName(classNames) method, when invoked, must return the list of elements with class names classNames for this.
次の XHTML 片が与えられたとする: ◎ Given the following XHTML fragment:
<div id="example"> <p id="p1" class="aaa bbb"/> <p id="p2" class="aaa ccc"/> <p id="p3" class="bbb ccc"/> </div>
document.getElementById(`example^l).getElementsByClassName(`aaa^l) の~callは、その中の 2 個の paragraph p1 と p2 からなる $HTMLCollection を返すことになる。 ◎ A call to document.getElementById("example").getElementsByClassName("aaa") would return a HTMLCollection with the two paragraphs p1 and p2 in it.
一方で, getElementsByClassName(`ccc bbb^l) の~callは その中の 1 個の~node p3 のみを返すことになる。 document.getElementById(`example^l).getElementsByClassName(`bbb ccc ^l) の~callも同じものを返すことになる。 ◎ A call to getElementsByClassName("ccc bbb") would only return one node, however, namely p3. A call to document.getElementById("example").getElementsByClassName("bbb ccc ") would return the same thing.
getElementsByClassName(`aaa,bbb^l) の~callは 1 個の~nodeも返さない。 上のどの要素も `aaa,bbb^c ~classに属さない。 ◎ A call to getElementsByClassName("aaa,bbb") would return no nodes; none of the elements above are in the aaa,bbb class.
- %element = %document . $createElement(localName [, options])
- `局所~名$が %localName にされた`要素$を返す( %document が`~HTML文書$である場合, %localName は小文字~化される)。 `要素$の`~ns$は,[ 次のいずれかに該当する場合は`~HTML~ns$ / 他の場合は ~NULL ]になる ⇒# %document は`~HTML文書$である / %document の`内容~型$doc ~EQ `application/xhtml+xml^l ◎ Returns an element with localName as local name (if document is an HTML document, localName gets lowercased). The element’s namespace is the HTML namespace when document is an HTML document or document’s content type is "application/xhtml+xml", and null otherwise.
- %localName が `Name$prod 生成規則に合致しない場合, `InvalidCharacterError$E 例外が投出される。 ◎ If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown.
- %options の $ElementCreationOptions.is を利用して,`~custom化された組込みの要素$を作成できる。 ◎ When supplied, options’s is can be used to create a customized built-in element.
- %element = %document . $createElementNS(namespace, qualifiedName [, options])
- `~ns$ %namespace に属するような,新たな`要素$を返す。 その ( `~ns接頭辞$ %接頭辞, `局所~名$ %局所~名 ) は、順に次のようにされる ⇒# %qualifiedName が `:^l (~U003A) を含むならば それを挟んだ ( 前, 後 ) の部分 / 他の場合は ( ~NULL, %qualifiedName ) ◎ Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName.
- %qualifiedName が `QName$prod 生成規則に合致しない場合、 `InvalidCharacterError$E 例外が投出される。 ◎ If qualifiedName does not match the QName production an "InvalidCharacterError" DOMException will be thrown.
- 次のいずれかに該当する場合, `NamespaceError$E 例外が投出される ⇒# %namespace ~EQ 空~文字列 ~AND %接頭辞 ~NEQ ~NULL / %namespace ~NEQ `~XML~ns$ ~AND %接頭辞 ~EQ `xml^l / %namespace ~NEQ `~XMLNS~ns$ ~AND %qualifiedName ~EQ `xmlns^l / %namespace ~NEQ `~XMLNS~ns$ ~AND %接頭辞 ~EQ `xmlns^l / %namespace ~EQ `~XMLNS~ns$ ~AND %qualifiedName ~NEQ `xmlns^l / %namespace ~EQ `~XMLNS~ns$ ~AND %接頭辞 ~NEQ `xmlns^l ◎ If one of the following conditions is true a "NamespaceError" DOMException will be thrown: • Namespace prefix is not null and namespace is the empty string. • Namespace prefix is "xml" and namespace is not the XML namespace. • qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. • namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".
- %documentFragment = %document . $createDocumentFragment()
- $DocumentFragment `~node$を返す。 ◎ Returns a DocumentFragment node.
- %text = %document . $createTextNode(data)
- 新たな $Text `~node$を返す — その`~data$は %data にされる。 ◎ Returns a Text node whose data is data.
- %text = %document . $createCDATASection(data)
- 新たな $CDATASection `~node$を返す — その`~data$は %data にされる。 ◎ Returns a CDATASection node whose data is data.
- %comment = %document . $createComment(data)
- 新たな $Comment `~node$を返す — その`~data$は %data にされる。 ◎ Returns a Comment node whose data is data.
- %processingInstruction = %document . $createProcessingInstruction(target, data)
- 新たな $ProcessingInstruction `~node$を返す — その $target は %target にされ, `~data$は %data にされる。 ◎ Returns a ProcessingInstruction node whose target is target and data is data.\
- 次のいずれかに該当する場合, `InvalidCharacterError$E 例外が投出される ⇒# %target は `Name$prod 生成規則に合致しない / %data は `?>^l を含んでいる ◎ If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown.
他が言明されない限り,所与の ( 局所~名, ~ns ) 用の `要素~interface@ は、 $Element とする。 ◎ The element interface for any name and namespace is Element, unless stated otherwise.
注記: 例えば,~HTML標準は、 ( `html$e, `~HTML~ns$ ) 用のそれを, $HTMLHtmlElement ~interfaceと定義している。 `HTML$r ◎ The HTML Standard will e.g. define that for html and the HTML namespace, the HTMLHtmlElement interface is used. [HTML]
@createElement(localName, options) ~method~手続きは: ◎ The createElement(localName, options) method, when invoked, must run these steps:
- ~IF[ %localName は `Name$prod 生成規則に合致しない ] ⇒ ~THROW `InvalidCharacterError$E ◎ If localName does not match the Name production, then throw an "InvalidCharacterError" DOMException.
- ~IF[ コレは`~HTML文書$ である ] ⇒ %localName ~SET `~ASCII小文字~化する$( %localName ) ◎ If this is an HTML document, then set localName to localName in ASCII lowercase.
- %is ~LET ~NULL ◎ Let is be null.
- ~IF[ %options は`辞書$である ] ⇒ %is ~SET [ %options[ "$ElementCreationOptions.is" ] ~NEQ ε ならば その値 / ~ELSE_ ~NULL ] ◎ If options is a dictionary and options’s is is present, then set is to it.
- %~ns ~LET [ 次が満たされるならば `~HTML~ns$ / ~ELSE_ ~NULL ] ⇒ [ コレは`~HTML文書$である ]~OR[ コレの`内容~型$doc ~EQ `application/xhtml+xml^l ] ◎ Let namespace be the HTML namespace, if this is an HTML document or this’s content type is "application/xhtml+xml", and null otherwise.
- ~RET `要素を作成する$( コレ, %localName, %~ns, ~NULL, %is, `同期~custom要素^i ) ◎ Return the result of creating an element given this, localName, namespace, null, is, and with the synchronous custom elements flag set.
`内部 createElementNS 手続き@ は、所与の ( %文書, %namespace, %qualifiedName, %options ) に対し,次を走らす: ◎ The internal createElementNS steps, given document, namespace, qualifiedName, and options, are as follows:
- ( %~ns, %接頭辞, %局所~名 ) ~LET `検証して抽出する$( %namespace, %qualifiedName ) ◎ Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
- ~RET `要素を作成する$( %文書, %局所~名, %~ns, %接頭辞, %is, `同期~custom要素^i ) ◎ Return the result of creating an element given document, localName, namespace, prefix, is, and with the synchronous custom elements flag set.
@createElementNS(namespace, qualifiedName, options) ~method~手続きは ⇒ ~RET `内部 createElementNS 手続き$( コレ, %namespace, %qualifiedName, %options ) ◎ The createElementNS(namespace, qualifiedName, options) method, when invoked, must return the result of running the internal createElementNS steps, given this, namespace, qualifiedName, and options.
注記: ~web互換性のため、[ $createElement() / $createElementNS() ]の %options 引数には文字列も許容される【無視されることになる】。 ◎ createElement() and createElementNS()'s options parameter is allowed to be a string for web compatibility.
@createTextNode(data) ~method~手続きは ⇒ ~RET `新たな~Text~node$( %data, コレ ) ◎ The createTextNode(data) method, when invoked, must return a new Text node with its data set to data and node document set to this.
注記: [ %data が `Char$prod 生成規則に合致しない文字を含む ]かどうかは、検査されない。 ◎ No check is performed that data consists of characters that match the Char production.
@createCDATASection(data) ~method~手続きは: ◎ The createCDATASection(data) method, when invoked, must run these steps:
- ~IF[ コレは`~HTML文書$である ] ⇒ ~THROW `NotSupportedError$E ◎ If this is an HTML document, then throw a "NotSupportedError" DOMException.
- ~IF[ %data は文字列 `]]>^l を包含する ] ⇒ ~THROW `InvalidCharacterError$E ◎ If data contains the string "]]>", then throw an "InvalidCharacterError" DOMException.
- ~RET 次のように設定された新たな $CDATASection `~node$ ⇒ ( `~data$, `~node文書$ ) ~SET ( %data, コレ ) ◎ Return a new CDATASection node with its data set to data and node document set to this.
@createComment(data) ~method~手続きは ⇒ ~RET 次のように設定された新たな $Comment `~node$ ⇒ ( `~data$, `~node文書$ ) ~SET ( %data, コレ ) ◎ The createComment(data) method, when invoked, must return a new Comment node with its data set to data and node document set to this.
注記: %data が[ `Char$prod 生成規則に合致しない文字を含む / 連続する 2 個の~hyphen( "--" )を含む / ~hyphenで終わる ]かどうかは、検査されない。 ◎ No check is performed that data consists of characters that match the Char production or that it contains two adjacent hyphens or ends with a hyphen.
@createProcessingInstruction(target, data) ~method~手続きは: ◎ The createProcessingInstruction(target, data) method, when invoked, must run these steps:
- ~IF[ %target は `Name$prod 生成規則に合致しない ] ⇒ ~THROW `InvalidCharacterError$E ◎ If target does not match the Name production, then throw an "InvalidCharacterError" DOMException.
- ~IF[ %data は文字列 `?>^l を含む ] ⇒ ~THROW `InvalidCharacterError$E ◎ If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
- ~RET 次のように設定された新たな $ProcessingInstruction `~node$ ⇒ ( $ProcessingInstruction.target, `~data$, `~node文書$ ) ~SET ( %target, %data, コレ ) ◎ Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
注記: [ %target が `xml^l または `:^l を含む / %data が `Char$prod 生成規則に合致しない文字を含む ]かどうかは、検査されない。 ◎ No check is performed that target contains "xml" or ":", or that data contains characters that match the Char production.
- %clone = %document . $importNode(node [, deep = false])
- %node の複製を返す。 %deep が~T の場合、複製には %node の`子孫$も含められる。 ◎ Returns a copy of node. If deep is true, the copy also includes the node’s descendants.
- %node が`文書$または`~shadow根$である場合, `NotSupportedError$E 例外が投出される。 ◎ If node is a document or a shadow root, throws a "NotSupportedError" DOMException.
- %node = %document . $adoptNode(node)
- %node を他の`文書$から移動させた上で,それを返す。 ◎ Moves node from another document and returns it.
- %node が`文書$である場合, `NotSupportedError$E 例外が投出される。 %node が`~shadow根$である場合, `HierarchyRequestError$E 例外が投出される。 ◎ If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException.
@importNode(node, deep) ~method~手続きは: ◎ The importNode(node, deep) method, when invoked, must run these steps:
- ~IF[ %node は `文書$または`~shadow根$である ] ⇒ ~THROW `NotSupportedError$E ◎ If node is a document or shadow root, then throw a "NotSupportedError" DOMException.
- ~RET `~nodeを~cloneする$( %node, コレ, [ %deep ~EQ ~T ならば `子も~cloneする^i / ~ELSE_ ε ] ) ◎ Return a clone of node, with this and the clone children flag set if deep is true.
`適用-可能な仕様$は、すべてまたは一部の`~node$用に `受入-時の手続き@ を定義してもヨイ。 この~algoは、`~nodeを受入する$~algo内から, ( `~node$, `文書$ ) を渡して呼出される。 ◎ Specifications may define adopting steps for all or some nodes. The algorithm is passed node and oldDocument, as indicated in the adopt algorithm.
%文書 に `~nodeを受入する@ ときは、所与の ( %node ) に対し,次を走らす: ◎ To adopt a node into a document, run these steps:
- %旧-文書 ~LET %node の`~node文書$ ◎ Let oldDocument be node’s node document.
- ~IF[ %node の`親$ ~NEQ ~NULL ] ⇒ `~nodeを除去する$( %node ) ◎ If node’s parent is non-null, then remove node.
-
~IF[ %文書 ~NEQ %旧-文書 ]: ◎ If document is not oldDocument, then:
-
%node の ~EACH( `~shadowも含む広義子孫$ %広義子孫 ) に対し ◎ For each inclusiveDescendant in node’s shadow-including inclusive descendants:
- %広義子孫 の`~node文書$ ~SET %文書 ◎ Set inclusiveDescendant’s node document to document.
- ~IF[ %広義子孫 は`要素$である ] ⇒ %広義子孫 の`属性o~list$内の ~EACH( %属性o ) に対し ⇒ %属性o の`~node文書$ ~SET %文書 ◎ If inclusiveDescendant is an element, then set the node document of each attribute in inclusiveDescendant’s attribute list to document.
- %node の ~EACH( `~shadowも含む広義子孫$ %広義子孫 ) に対し ⇒ ~IF[ %広義子孫 は`~custom$である ] ⇒ `~custom要素~callback反応を~enqueueする$( %広義子孫, `adoptedCallback^l, « %旧-文書, %文書 » ) ◎ For each inclusiveDescendant in node’s shadow-including inclusive descendants that is custom, enqueue a custom element callback reaction with inclusiveDescendant, callback name "adoptedCallback", and an argument list containing oldDocument and document.
- %node の ~EACH( `~shadowも含む広義子孫$ %広義子孫 ) に対し,`~shadowも含む~tree順序$で ⇒ `受入-時の手続き$に ( %広義子孫, %旧-文書 ) を渡して走らす ◎ For each inclusiveDescendant in node’s shadow-including inclusive descendants, in shadow-including tree order, run the adopting steps with inclusiveDescendant and oldDocument.
-
@adoptNode(node) ~method~手続きは: ◎ The adoptNode(node) method, when invoked, must run these steps:
- ~IF[ %node は`文書$である ] ⇒ ~THROW `NotSupportedError$E ◎ If node is a document, then throw a "NotSupportedError" DOMException.
- ~IF[ %node は`~shadow根$である ] ⇒ ~THROW `HierarchyRequestError$E ◎ If node is a shadow root, then throw a "HierarchyRequestError" DOMException.
- ~IF[ %node は`文書片$である ]~AND[ %node の`~host$ ~NEQ ~NULL ] ⇒ ~RET ◎ If node is a DocumentFragment node whose host is non-null, then return.
- コレに`~nodeを受入する$( %node ) ◎ Adopt node into this.
- ~RET %node ◎ Return node.
@createAttribute(localName) ~method~手続きは: ◎ The createAttribute(localName) method, when invoked, must run these steps:
- ~IF[ %localName は~XMLの `Name$prod 生成規則に合致しない ] ⇒ ~THROW `InvalidCharacterError$E ◎ If localName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
- ~IF[ コレは`~HTML文書$である ] ⇒ %localName ~SET `~ASCII小文字~化する$( %localName ) ◎ If this is an HTML document, then set localName to localName in ASCII lowercase.
- ~RET 次のように設定された新たな`属性o$ ⇒# `局所~名$a ~SET %localName, `~node文書$ ~SET コレ ◎ Return a new attribute whose local name is localName and node document is this.
@createAttributeNS(namespace, qualifiedName) ~method~手続きは: ◎ The createAttributeNS(namespace, qualifiedName) method, when invoked, must run these steps:
- ~RET 次のように設定された新たな`属性o$ ⇒# `~ns$a ~SET %~ns, `~ns接頭辞$a ~SET %接頭辞, `局所~名$a ~SET %局所~名, `~node文書$ ~SET コレ ◎ Return a new attribute whose namespace is namespace, namespace prefix is prefix, local name is localName, and node document is this.
@createEvent(interface) ~method~手続きは: ◎ The createEvent(interface) method, when invoked, must run these steps:
- %構築子 ~LET ~NULL ◎ Let constructor be null.
-
~IF[ %interface は[ 下の表のいずれかの行の 1 列目の文字列 ]に `~ASCII大小無視$で合致する ] ⇒ %構築子 ~SET [ 合致した行の 2 列目の~interface ]の構築子 ◎ If interface is an ASCII case-insensitive match for any of the strings in the first column in the following table, then set constructor to the interface in the second column on the same row as the matching string:
文字列◎ String ~interface◎ Interface 仕様(空欄はこの仕様)◎ Notes `beforeunloadevent^l $BeforeUnloadEvent `HTML$r `compositionevent^l $CompositionEvent `UIEVENTS$r `customevent^l $CustomEvent `devicemotionevent^l $DeviceMotionEvent `DEVICE-ORIENTATION$r `deviceorientationevent^l $DeviceOrientationEvent 同上 `dragevent^l $DragEvent `HTML$r `event^l $Event `events^l 同上 `focusevent^l $FocusEvent `UIEVENTS$r `hashchangeevent^l $HashChangeEvent `HTML$r `htmlevents^l $Event `keyboardevent^l $KeyboardEvent `UIEVENTS$r `messageevent^l $MessageEvent `HTML$r `mouseevent^l $MouseEvent `UIEVENTS$r `mouseevents^l 同上 同上 `storageevent^l $StorageEvent `HTML$r `svgevents^l $Event `textevent^l $CompositionEvent `UIEVENTS$r `touchevent^l $TouchEvent `TOUCH-EVENTS$r `uievent^l $UIEvent `UIEVENTS$r `uievents^l 同上 同上 - ~IF[ %構築子 ~EQ ~NULL ] ⇒ ~THROW `NotSupportedError$E ◎ If constructor is null, then throw a "NotSupportedError" DOMException.
-
~IF[ %構築子 が指示する~interfaceは,コレに`関連な大域~obj$に公開されていない ] ⇒ ~THROW `NotSupportedError$E ◎ If the interface indicated by constructor is not exposed on the relevant global object of this, then throw a "NotSupportedError" DOMException.
注記: 概して~UAは、環境設定によっては,~touch~eventの~supportを不能化する — その場合、この段が $TouchEvent ~interface用に誘発されることになる。 ◎ Typically user agents disable support for touch events in some configurations, in which case this clause would be triggered for the interface TouchEvent.
- %~event ~LET `~eventを作成する$( %構築子 ) ◎ Let event be the result of creating an event given constructor.
- %~event の次に挙げる属性を初期化する ⇒# $Event.type ~SET 空~文字列, $Event.timeStamp ~SET `現在の高分解能~時刻$, $Event.isTrusted ~SET ~F ◎ Initialize event’s type attribute to the empty string. ◎ Initialize event’s timeStamp attribute to a DOMHighResTimeStamp representing the high resolution time from the time origin to now. ◎ Initialize event’s isTrusted attribute to false.
- %~event の`初期化-済み$f ~SET ~F ◎ Unset event’s initialized flag.
- ~RET %~event ◎ Return event.
注記: 代わりに,`~event$構築子が利用されるべきである。 ◎ Event constructors ought to be used instead.
@createRange() ~method~手続きは ⇒ ~RET 次のように設定された新たな`~live範囲o$ ⇒# `始端$ ~SET `境界点$( コレ, 0 ), `終端$ ~SET `境界点$( コレ, 0 ) ◎ The createRange() method, when invoked, must return a new live range with (this, 0) as its start an end.
注記: 代わりに, $Range.Range() 構築子を利用できる。 ◎ The Range() constructor can be used instead.
4.5.1. ^@DOMImplementation ~interface
~UA は、`文書$が作成された際には, $DOMImplementation ~objを作成して, `文書$にそれを結付けるモノトスル。 ◎ User agents must create a DOMImplementation object whenever a document is created and associate it with that document.
!! [`Exposed$=Window] interface @DOMImplementation { [`NewObject$] $DocumentType $createDocumentType($DOMString qualifiedName, $DOMString publicId, $DOMString systemId); [`NewObject$] $XMLDocument $createDocument($DOMString? %namespace, [`LegacyNullToEmptyString$] $DOMString %qualifiedName, optional $DocumentType? %doctype = null); [`NewObject$] $Document $createHTMLDocument(optional $DOMString title); $boolean $hasFeature(); // 無用の長物 — 常に true を返す }; !- %doctype = %document . $Document.implementation . $createDocumentType(qualifiedName, publicId, systemId)
- 所与の[ %qualifiedName, %publicId, %systemId ]を伴う`~doctype$を返す。 %qualifiedName が[ `Name$prod 生成規則に合致しない場合は `InvalidCharacterError$E 例外 / `QName$prod 生成規則に合致しない場合は `NamespaceError$E 例外 ]が投出される。 ◎ Returns a doctype, with the given qualifiedName, publicId, and systemId. If qualifiedName does not match the Name production, an "InvalidCharacterError" DOMException is thrown, and if it does not match the QName production, a "NamespaceError" DOMException is thrown.
- %doc = %document . $Document.implementation . $createDocument(namespace, qualifiedName [, doctype = null])
- `局所~名$が %qualifiedName で`~ns$が %namespace ( %qualifiedName が空~文字列でなければ)の`文書~要素$を伴い, %doctype が与えられていれば`~doctype$がそれに設定された $XMLDocument を返す。 ◎ Returns an XMLDocument, with a document element whose local name is qualifiedName and whose namespace is namespace (unless qualifiedName is the empty string), and with doctype, if it is given, as its doctype.
- この~methodは、$Document.createElementNS() ~methodと同じ例外を, ( %namespace, %qualifiedName ) で呼出したときに投出する。 ◎ This method throws the same exceptions as the createElementNS() method, when invoked with namespace and qualifiedName.
- %doc = %document . $Document.implementation . $createHTMLDocument([title])
- 基本~構造が構築-済みの`~tree$を伴う`文書$を返す。 %title 引数が省略されていなければ `title$e 要素も含められる。 ◎ Returns a document, with a basic tree already constructed including a title element, unless the title argument is omitted.
@createDocumentType(qualifiedName, publicId, systemId) ~method~手続きは: ◎ The createDocumentType(qualifiedName, publicId, systemId) method, when invoked, must run these steps:
- `有修飾~名として検証する$( %qualifiedName ) ◎ Validate qualifiedName.
- ~RET 次のように設定された新たな`~doctype$ ⇒# `名前$dT ~SET %qualifiedName, `~publicID$dT ~SET %publicId, `~systemID$dT ~SET %systemId, `~node文書$ ~SET コレを結付けている`文書$ ◎ Return a new doctype, with qualifiedName as its name, publicId as its public ID, and systemId as its system ID, and with its node document set to the associated document of this.
注記: [ %publicId を成す符号位置~並びが `PubidChar^prod 生成規則に合致しない / %systemId が文字 `"^l や `'^l を含む ]かどうかは、検査されない。 ◎ No check is performed that publicId code points match the PubidChar production or that systemId does not contain both a '"' and a "'".
@createDocument(namespace, qualifiedName, doctype) ~method~手続きは: ◎ The createDocument(namespace, qualifiedName, doctype) method, when invoked, must run these steps:
- %文書 ~LET 新たな $XMLDocument ◎ Let document be a new XMLDocument.
- %要素 ~LET ~NULL ◎ Let element be null.
- ~IF[ %qualifiedName ~NEQ 空~文字列 ] ⇒ %要素 ~SET `内部 createElementNS 手続き$( コレ, %namespace, %qualifiedName, 空~辞書 ) ◎ If qualifiedName is not the empty string, then set element to the result of running the internal createElementNS steps, given document, namespace, qualifiedName, and an empty dictionary.
- ~IF[ %doctype ~NEQ ~NULL ] ⇒ %文書 に`~nodeを付加する$( %doctype ) ◎ If doctype is non-null, append doctype to document.
- ~IF[ %要素 ~NEQ ~NULL ] ⇒ %文書 に`~nodeを付加する$( %要素 ) ◎ If element is non-null, append element to document.
- %文書 の`生成元$doc ~SET コレに結付けられている`文書$の`生成元$doc ◎ document’s origin is this’s associated document’s origin.
- %文書 の`内容~型$doc ~SET %namespace に応じて ⇒# `~HTML~ns$ならば `application/xhtml+xml^c / `~SVG~ns$ならば `image/svg+xml^c / ~ELSE_ `application/xml^c ◎ document’s content type is determined by namespace: ◎ HTML namespace • application/xhtml+xml SVG namespace • image/svg+xml Any other namespace • application/xml
- ~RET %文書 ◎ Return document.
@createHTMLDocument(title) ~method~手続きは: ◎ The createHTMLDocument(title) method, when invoked, must run these steps:
- %文書 ~LET 次のように設定された新たな`文書$ ⇒# `種別$doc ~SET `html^l, `内容~型$doc ~SET `text/html^l ◎ Let doc be a new document that is an HTML document. ◎ Set doc’s content type to "text/html".
- %文書 に`~nodeを付加する$( 次のように設定された新たな`~doctype$ ) ⇒# `名前$dT ~SET `html^l, `~node文書$ ~SET %文書 ◎ Append a new doctype, with "html" as its name and with its node document set to doc, to doc.
- `html 要素^V ~LET `要素を作成する$( %文書, `html^l, `~HTML~ns$ ) ◎ Append the result of creating an element given doc, html, and the HTML namespace, to doc.
- %文書 に`~nodeを付加する$( `html 要素^V ) ◎ ↑
- `head 要素^V ~LET `要素を作成する$( %文書, `head^l, `~HTML~ns$ ) ◎ Append the result of creating an element given doc, head, and the HTML namespace, to the html element created earlier.
- `html 要素^V に`~nodeを付加する$( `head 要素^V ) ◎ ↑
-
~IF[ %title 引数は与えられている ]: ◎ If title is given:
- `title 要素^V ~LET `要素を作成する$( %文書, `title^l, `~HTML~ns$ ) ◎ Append the result of creating an element given doc, title, and the HTML namespace, to the head element created earlier.
- `head 要素^V に`~nodeを付加する$( `title 要素^V ) ◎ ↑
- `title 要素^V に`~nodeを付加する$( `新たな~Text~node$( %title, %文書 ) ) ◎ Append a new Text node, with its data set to title (which could be the empty string) and its node document set to doc, to the title element created earlier.
- `html 要素^V に`~nodeを付加する$( `要素を作成する$( %文書, `body^l, `~HTML~ns$ ) ) ◎ Append the result of creating an element given doc, body, and the HTML namespace, to the html element created earlier.
- %文書 の`生成元$doc ~SET コレに結付けられている`文書$の`生成元$doc `HTML$r ◎ doc’s origin is this’s associated document’s origin.
- ~RET %文書 ◎ Return doc.
@hasFeature() ~method~手続きは ⇒ ~RET ~T ◎ The hasFeature() method, when invoked, must return true.
注記: $hasFeature() は元々、~UAが所与の~DOM特能の~supportを主張しているかどうかを報告するものであったが、経験から,単に欲される[ ~obj/属性/~method ]が存在するかどうか検査する用途には ほど遠いことが~~判明している。 そのようなわけで,それは最早~利用されないが、古い~pageが働き続けられるよう存続している(単に ~T を返す)。 ◎ hasFeature() originally would report whether the user agent claimed to support a given DOM feature, but experience proved it was not nearly as reliable or granular as simply checking whether the desired objects, attributes, or methods existed. As such, it is no longer to be used, but continues to exist (and simply returns true) so that old pages don’t stop working.
4.6. ^@DocumentType ~interface
!! [`Exposed$=Window] interface @DocumentType : $Node { ~RA $DOMString $name; ~RA $DOMString $publicId; ~RA $DOMString $systemId; }; !$DocumentType `~node$は、単に `~doctype@ とも称される。 ◎ DocumentType nodes are simply known as doctypes.
各 `~doctype$には、次に挙げるものが結付けられる(いずれも,文字列):
- `名前@dT
- 常に,`~doctype$の作成-時に与えられる。
- `~publicID@dT
- `~systemID@dT
- これらは、`~doctype$の作成-時に明示的に与えられない限り,空~文字列とする。
4.7. ^@DocumentFragment ~interface
!! [`Exposed$=Window] interface @DocumentFragment : $Node { `DocumentFragment$mc(); }; !$DocumentFragment `~node$は、単に `文書片@ ( `document fragment^en )とも称される。 【これは、この訳にて導入した非公式な用語である。】
各 `文書片$には、次に挙げるものが結付けられる:
- `~host@
- [ ~NULL / 異なる`~node~tree$内に在る`要素$ ]であり、他が言明されない限り,~NULL とする。
~obj %A が ~obj %B の `~hostも含む広義先祖@ であるとは、次のいずれかが満たされることを意味する: ◎ An object A is a host-including inclusive ancestor of an object B, if either\
- %A は %B の`広義先祖$である ◎ A is an inclusive ancestor of B, or\
- %B の`根$の`~host$を %H とするとき,次が満たされる ⇒ [ %H ~NEQ ~NULL ]~AND[ %A は %H の`~hostも含む広義先祖$である ] ◎ if B’s root has a non-null host and A is a host-including inclusive ancestor of B’s root’s host.
注記: `文書片$の`~host$は,[ `~shadow根$, ~HTMLの `template$e 要素 ]で有用になる概念であり、[ `~nodeを子の前に前挿入する$/`子を~nodeに置換する$ ]~algoに影響iする。 ◎ The DocumentFragment node’s host concept is useful for HTML’s template element and for shadow roots, and impacts the pre-insert and replace algorithms.
- %tree = $DocumentFragment()
- 新たな`文書片$を返す。 ◎ Returns a new DocumentFragment node.
@DocumentFragment() 構築子~手続きは ⇒ コレの`~node文書$ ~SET `現在の大域~obj$に`結付けられている文書$ ◎ The DocumentFragment() constructor, when invoked, must return a new DocumentFragment node whose node document is current global object’s associated Document.
4.8. ^@ShadowRoot ~interface
!! [`Exposed$=Window] interface @ShadowRoot : $DocumentFragment { ~RA $ShadowRootMode $mode; ~RA $Element $host; attribute $EventHandler $onslotchange; }; enum @ShadowRootMode { `open@l, `closed@l }; !$ShadowRoot ~nodeは、単に `~shadow根@ ( `shadow root^en )とも称される。 ◎ ShadowRoot nodes are simply known as shadow roots.
各 `~shadow根$には、次に挙げるものが結付けられる:
- `~mode@sR
- [ `open^l, `closed^l ]のいずれか。
- `~focusを委譲する@sR
- 初期~時は ~F をとるとする。
- `要素の内部特能から可用@sR
- 初期~時は ~F をとるとする。
`~shadow根$の`~host$が ~NULL になることは決してない。 ◎ Shadow roots’s associated host is never null.
`~shadow根$ %根 の`親~targetを取得する$ときは、所与の~event %~event に対し,次を走らす: ◎ A shadow root’s get the parent algorithm, given an event,\
- ~IF[ %~event の`~composed$f ~EQ ~F ]~AND[ %根 ~EQ [[[ %~event の`経路$ ]内の最初の構造体 ]の`呼出n~target$evP ]の`根$ ] ⇒ ~RET ~NULL ◎ returns null if event’s composed flag is unset and shadow root is the root of event’s path’s first struct’s invocation target, and\
- ~RET %根 の`~host$ ◎ shadow root’s host otherwise.
@onslotchange は、 `onslotchange@c `~event~handler$用の`~event~handler~IDL属性$である — その`~event~handler~event型$は `slotchange$et とする。 ◎ The onslotchange attribute is an event handler IDL attribute for the onslotchange event handler, whose event handler event type is slotchange.
`~node~tree$ %~tree における `~shadowも含む~tree順序@ は、 `~shadowも含む深優先前順走査@ による順序であり,次に従う ⇒ %~tree に対する深優先前順走査 【すなわち,通常の~tree順序】 に従いつつ, %~tree において[ `~shadow~host$である`要素$ %要素 ]に遭遇した各所では,[[ %要素 の`~shadow根$elmを根とする`~node~tree$ ]における,`~shadowも含む深優先前順走査$ ]に従う。 ◎ In shadow-including tree order is shadow-including preorder, depth-first traversal of a node tree. Shadow-including preorder, depth-first traversal of a node tree tree is preorder, depth-first traversal of tree, with for each shadow host encountered in tree, shadow-including preorder, depth-first traversal of that element’s shadow root’s node tree just after it is encountered.
~obj %O の `~shadowも含む根@ とは、 %O の`根$を %根 とするとき,[ %根 は`~shadow根$であるならば %根 の`~host$の`~shadowも含む根$ / ~ELSE_ %根 ]である。 ◎ The shadow-including root of an object is its root’s host’s shadow-including root, if the object’s root is a shadow root, and its root otherwise.
~obj %A が~obj %B の `~shadowも含む子孫@ であるとは、次を意味する ⇒ [ %A は %B の`子孫$である ]~OR[ %A の`根$は次を満たす ] ⇒ [ `~shadow根$である ]~AND[ その`~host$は %B の`~shadowも含む広義子孫$である ] ◎ An object A is a shadow-including descendant of an object B, if A is a descendant of B, or A’s root is a shadow root and A’s root’s host is a shadow-including inclusive descendant of B.
~obj %A が~obj %B の `~shadowも含む広義子孫@ であるとは、次を意味する ⇒ [ %A ~EQ %B ]~OR[ %A は %B の`~shadowも含む子孫$である ] ◎ A shadow-including inclusive descendant is an object or one of its shadow-including descendants.
~obj %A が~obj %B の `~shadowも含む先祖@ であるとは、次を意味する ⇒ %B は %A の`~shadowも含む子孫$である ◎ An object A is a shadow-including ancestor of an object B, if and only if B is a shadow-including descendant of A.
~obj %A が~obj %B の `~shadowも含む広義先祖@ であるとは、次を意味する ⇒ [ %A ~EQ %B ]~OR[ %A は %B の`~shadowも含む先祖$である ] ◎ A shadow-including inclusive ancestor is an object or one of its shadow-including ancestors.
`~node$ %A が `~node$ %B からは `閉な~shadowで隠されて@ いるとは、 %A の`根$ %根 が次をすべて満たすことを意味する: ◎ A node A is closed-shadow-hidden from a node B if all of the following conditions are true:
- %根 は`~shadow根$である ◎ A’s root is a shadow root.
- %根 は %B の`~shadowも含む広義先祖$でない ◎ A’s root is not a shadow-including inclusive ancestor of B.
- [ %根 の`~mode$sR ~EQ `closed^l ]~OR[ %根 の`~host$は %B からは`閉な~shadowで隠されて$いる ] ◎ A’s root is a shadow root whose mode is "closed" or A’s root’s host is closed-shadow-hidden from B.
~obj %A を ~obj %B に向けて `~targetし直す@ ときは、次を走らす: ◎ To retarget an object A against an object B,\
-
~WHILE 無条件: ◎ repeat these steps until they return an object:
- %根 ~LET %A の`根$ ◎ ↓
-
~IF[ 次のいずれかが満たされる ]…: ◎ If one of the following is true
- %A は`~node$でない ◎ A is not a node
- %根 は`~shadow根$でない ◎ A’s root is not a shadow root
- [ %B は`~node$である ]~AND[ %根 は %B の`~shadowも含む広義先祖$である ] ◎ B is a node and A’s root is a shadow-including inclusive ancestor of B
…ならば ⇒ ~RET %A ◎ then return A.
- %A ~SET %根 の`~host$ ◎ Set A to A’s root’s host.
注記: `~targetし直す$~algoは、~eventの`配送-$時, および `FULLSCREEN$r などの他の仕様により利用される。 ◎ The retargeting algorithm is used by event dispatch as well as other specifications, such as Fullscreen. [FULLSCREEN]
4.9. ^@Element ~interface
!! [`Exposed$=Window] interface @Element : $Node { ~RA $DOMString? $namespaceURI; ~RA $DOMString? $prefix; ~RA $DOMString $localName; ~RA $DOMString $tagName; [`CEReactions$] attribute $DOMString $id; [`CEReactions$] attribute $DOMString $className; [`SameObject$, `PutForwards$=$DOMTokenList.value] ~RA $DOMTokenList $classList; [`CEReactions$, `Unscopable$] attribute $DOMString $slot; $boolean $hasAttributes(); [`SameObject$] ~RA $NamedNodeMap $attributes; $sequence<$DOMString> $getAttributeNames(); $DOMString? $getAttribute($DOMString %qualifiedName); $DOMString? $getAttributeNS($DOMString? %namespace, $DOMString %localName); [`CEReactions$] $undefined $setAttribute($DOMString %qualifiedName, $DOMString %value); [`CEReactions$] $undefined $setAttributeNS($DOMString? %namespace, $DOMString %qualifiedName, $DOMString %value); [`CEReactions$] $undefined $removeAttribute($DOMString %qualifiedName); [`CEReactions$] $undefined $removeAttributeNS($DOMString? %namespace, $DOMString %localName); [`CEReactions$] $boolean $toggleAttribute($DOMString %qualifiedName, optional $boolean %force); $boolean $hasAttribute($DOMString %qualifiedName); $boolean $hasAttributeNS($DOMString? %namespace, $DOMString %localName); $Attr? $getAttributeNode($DOMString %qualifiedName); $Attr? $getAttributeNodeNS($DOMString? %namespace, $DOMString %localName); [`CEReactions$] $Attr? $setAttributeNode($Attr %attr); [`CEReactions$] $Attr? $setAttributeNodeNS($Attr %attr); [`CEReactions$] $Attr $removeAttributeNode($Attr %attr); $ShadowRoot $attachShadow($ShadowRootInit %init); ~RA $ShadowRoot? $shadowRoot; $Element? $closest($DOMString %selectors); $boolean $matches($DOMString %selectors); $boolean $webkitMatchesSelector($DOMString %selectors); // $matches の旧来の別名 $HTMLCollection $getElementsByTagName($DOMString %qualifiedName); $HTMLCollection $getElementsByTagNameNS($DOMString? %namespace, $DOMString %localName); $HTMLCollection $getElementsByClassName($DOMString %classNames); [`CEReactions$] $Element? $insertAdjacentElement($DOMString %where, $Element %element); // $undefined $insertAdjacentText($DOMString %where, $DOMString %data); // }; dictionary @@ShadowRootInit { required $ShadowRootMode @mode; boolean @delegatesFocus = false; }; !$@Element `~node$は、単に `要素@ ( `element^en )とも称される。 ◎ Element nodes are simply known as elements.
各 `要素$には、次に挙げるものが結付けられ,いずれも`要素を作成する$ときに初期化される ⇒# `~ns@, `~ns接頭辞@, `局所~名@, `~custom要素~状態@, `~custom要素~定義@, `~is0値@ ◎ Elements have an associated namespace, namespace prefix, local name, custom element state, custom element definition, is value. When an element is created, all of these values are initialized.
`要素$ %要素 の`~custom要素~状態$ %状態 は:
- 次のいずれかになるとする ⇒# `undefined^l, `failed^l, `uncustomized^l, `precustomized^l, `custom^l
- %要素 は次を満たすならば `定義-済み@ とされる ⇒ %状態 ~IN { `uncustomized^l, `custom^l }
- %要素 は次を満たすならば `~custom@ であるとされる ⇒ %状態 ~EQ `custom^l
注記:
要素が`定義-済み$かどうかは、
:defined
疑似類の挙動を決定するときに利用される。
要素が`~custom$であるかどうかは、
変異~algo
の挙動を決定するときに利用される。
[
`failed^l, `precustomized^l
]状態は、`~custom要素~構築子$が初回に正しく実行するのに失敗した場合に,`要素を昇格する$ときに再び実行されないことを確保するために利用される。
◎
Whether or not an element is defined is used to determine the behavior of the :defined pseudo-class. Whether or not an element is custom is used to determine the behavior of the mutation algorithms. The "failed" and "precustomized" states are used to ensure that if a custom element constructor fails to execute correctly the first time, it is not executed again by an upgrade.
要素がとり得るこれら 4 種の状態を,次の~codeで~~説明する: ◎ The following code illustrates elements in each of these four states:
<!DOCTYPE html> <script> window.customElements.define( "sw-rey", class extends HTMLElement {} ); window.customElements.define( "sw-finn", class extends HTMLElement {}, { extends: "p" } ); window.customElements.define( "sw-kylo", class extends HTMLElement { constructor() { /* `super()^c は、この例からは意図的に省略している。 ◎ super() intentionally omitted for this example */ } }); </script> <!-- `undefined^l (`定義-済み$でも`~custom$でもない) ◎ "undefined" (not defined, not custom) --> <sw-han></sw-han> <p is="sw-luke"></p> <p is="asdf"></p> <!-- `failed^l (`定義-済み$でも`~custom$でもない) ◎ "failed" (not defined, not custom) --> <sw-kylo></sw-kylo> <!-- `uncustomized^l (`定義-済み$だが`~custom$ではない) ◎ "uncustomized" (defined, not custom) --> <p></p> <asdf></asdf> <!-- `custom^l (`定義-済み$かつ`~custom$である) ◎ "custom" (defined, custom) --> <sw-rey></sw-rey> <p is="sw-finn"></p>
各 `要素$には、 `~shadow根@elm も結付けられる: ◎ Elements also have an associated shadow root\
- それは,[ ~NULL / `~shadow根$ ]であり、他が言明されない限り,~NULL とする。 ◎ (null or a shadow root). It is null unless otherwise stated.\
- ~NULL でない場合、当の`要素$は `~shadow~host@ であるとされる。 【すなわち,要素は、`~shadow根$elmを根とする ある`~shadow~tree$を~hostしている(言い換えれば、ある`~shadow根$の`~host$である)。】 ◎ An element is a shadow host if its shadow root is non-null.
`要素$ %要素 の `有修飾~名@ は、 %要素 の`~ns接頭辞$ %接頭辞 に応じて,[ ~NULL ならば %要素 の`局所~名$ / 非 ~NULL ならば[ %接頭辞, `:^l, %要素 の`局所~名$ ]の並び ]になる。 ◎ An element’s qualified name is its local name if its namespace prefix is null, and its namespace prefix, followed by ":", followed by its local name, otherwise.
`要素$ %要素 の `~HTML大文字~化~有修飾~名@ は、次の手続きの結果を返す: ◎ An element’s HTML-uppercased qualified name is the return value of these steps:
- %有修飾~名 ~LET %要素 の`有修飾~名$ ◎ Let qualifiedName be this’s qualified name.
- ~IF[ %要素 は`~HTML~ns$に属する ]~AND[ %要素 の`~node文書$は`~HTML文書$である ] ⇒ ~RET `~ASCII大文字~化する$( %有修飾~名 ) ◎ If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII uppercase.
- ~RET %有修飾~名 ◎ Return qualifiedName.
注記: ~UAは、`有修飾~名$と`~HTML大文字~化~有修飾~名$を内部~slotに格納して最適化することもできる。 ◎ User agents could optimize qualified name and HTML-uppercased qualified name by storing them in internal slots.
`要素を作成する@ ときは、所与の ⇒# %文書, %局所~名, %~ns, %接頭辞 (省略時は ~NULL ), %is (省略時は ~NULL ), %同期~custom要素~flag ~IN { `同期~custom要素^i, ε }(省略時は ε ) ◎終 に対し,次の手続きを走らす: ◎ To create an element, given a document, localName, namespace, and optional prefix, is, and synchronous custom elements flag, run these steps:
- %結果 ~LET ~NULL ◎ If prefix was not given, let prefix be null. ◎ If is was not given, let is be null. ◎ Let result be null.
- %定義 ~LET `~custom要素~定義を検索する$( %文書, %~ns, %局所~名, %is ) ◎ Let definition be the result of looking up a custom element definition given document, namespace, localName, and is.
-
~IF[ %定義 ~NEQ ~NULL ]~AND[ %定義 の`名前$cD ~NEQ %定義 の`局所~名$cD ](すなわち,%定義 は`~custom化された組込みの要素$を表現する): ◎ If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then:
- %~interface ~LET ( %局所~名, `~HTML~ns$ ) 用の`要素~interface$ ◎ Let interface be the element interface for localName and the HTML namespace.
-
%結果 ~SET %~interface を実装し, 次のように設定された新たな`要素$ ⇒# `属性o~list$ ~SET 新たな`~list$, `~ns$ ~SET `~HTML~ns$, `~ns接頭辞$ ~SET %接頭辞 , `局所~名$ ~SET %局所~名, `~custom要素~状態$ ~SET `undefined^l, `~custom要素~定義$ ~SET ~NULL, `~is0値$ ~SET %is, `~node文書$ ~SET %文書 ◎ Set result to a new element that implements interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to is, and node document set to document.
-
~IF[ %同期~custom要素~flag ~NEQ ε ] ⇒ `要素を昇格する$( %定義, %要素 ) ◎ If the synchronous custom elements flag is set, then run this step while catching any exceptions: • Upgrade element using definition.
この段から例外が投出されたときは、~catchして: ◎ If this step threw an exception, then:
- `その例外を報告する$ ◎ Report the exception.
- %結果 の`~custom要素~状態$ ~SET `failed^l ◎ Set result’s custom element state to "failed".
- ~ELSE ⇒ `~custom要素~昇格~反応を~enqueueする$( %結果, %定義 ) ◎ Otherwise, enqueue a custom element upgrade reaction given result and definition.
-
~ELIF[ %定義 ~NEQ ~NULL ]~AND[ %同期~custom要素~flag ~NEQ ε ]: ◎ Otherwise, if definition is non-null, then:
この段から例外が投出されたときは、~catchして,下の (A) に~~移行するとする ◎ If the synchronous custom elements flag is set, then run these steps while catching any exceptions:
- %C ~LET %定義 の`構築子$cD ◎ Let C be definition’s constructor.
- %結果 ~SET `~callback関数で構築する$( %C, 空な引数~list ) ◎ Set result to the result of constructing C, with no arguments.
- ~Assert: %結果 の[ `~custom要素~状態$, `~custom要素~定義$ ]は初期化-済みである ◎ Assert: result’s custom element state and custom element definition are initialized.
-
~Assert: %結果 の`~ns$ ~EQ `~HTML~ns$ ◎ Assert: result’s namespace is the HTML namespace.
注記: ~IDLにより, %結果 は $HTMLElement ~objになるよう施行され、そのような~objは,すべて`~HTML~ns$を利用する。 ◎ IDL enforces that result is an HTMLElement object, which all use the HTML namespace.
-
~IF[ %結果 は下に挙げるいずれかを満たす ] ⇒ ~THROW `NotSupportedError$E: ◎ ↓
- %結果 の`属性o~list$は`空$でない ◎ If result’s attribute list is not empty, then throw a "NotSupportedError" DOMException.
- %結果 は`子$を持つ ◎ If result has children, then throw a "NotSupportedError" DOMException.
- %結果 の`親$ ~NEQ ~NULL ◎ If result’s parent is not null, then throw a "NotSupportedError" DOMException.
- %結果 の`~node文書$ ~NEQ %文書 ◎ If result’s node document is not document, then throw a "NotSupportedError" DOMException.
- %結果 の`局所~名$ ~NEQ %局所~名 ◎ If result’s local name is not equal to localName, then throw a "NotSupportedError" DOMException.
- %結果 の`~ns接頭辞$ ~SET %接頭辞 ◎ Set result’s namespace prefix to prefix.
- %結果 の`~is0値$ ~SET ~NULL ◎ Set result’s is value to null.
(A) — 上の手続きにて,例外が投出されたときは: ◎ If any of these steps threw an exception, then:
- `その例外を報告する$ ◎ Report the exception.
-
%結果 ~SET 次のように設定された新たな`要素$ ⇒# $HTMLUnknownElement ~interfaceを実装する, `属性o~list$ ~SET 新たな`~list$, `~ns$ ~SET `~HTML~ns$, `~ns接頭辞$ ~SET %接頭辞, `局所~名$ ~SET %局所~名, `~custom要素~状態$ ~SET `failed^l, `~custom要素~定義$ ~SET ~NULL, `~is0値$ ~SET ~NULL, `~node文書$ ~SET %文書 ◎ Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document.
-
~ELIF[ %定義 ~NEQ ~NULL ]: ◎ ↑ ◎ Otherwise:
-
%結果 ~SET 次のように設定された新たな`要素$ ⇒# $HTMLElement を実装する, `属性o~list$ ~SET 新たな`~list$, `~ns$ ~SET `~HTML~ns$, `~ns接頭辞$ ~SET %接頭辞 , `局所~名$ ~SET %局所~名, `~custom要素~状態$ ~SET `undefined^l, `~custom要素~定義$ ~SET ~NULL, `~is0値$ ~SET ~NULL, `~node文書$ ~SET %文書 ◎ Set result to a new element that implements the HTMLElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to null, and node document set to document.
- `~custom要素~昇格~反応を~enqueueする$( %結果, %定義 ) ◎ Enqueue a custom element upgrade reaction given result and definition.
-
-
~ELSE: ◎ Otherwise:
- %~interface ~LET ( %局所~名, %~ns ) 用の`要素~interface$ ◎ Let interface be the element interface for localName and namespace.
-
%結果 ~SET %~interface を実装し, 次のように設定された新たな`要素$ ⇒# `属性o~list$ ~SET 新たな`~list$, `~ns$ ~SET %~ns, `~ns接頭辞$ ~SET %接頭辞 , `局所~名$ ~SET %局所~名, `~custom要素~状態$ ~SET `uncustomized^l, `~custom要素~定義$ ~SET ~NULL, `~is0値$ ~SET %is, `~node文書$ ~SET %文書 ◎ Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix, local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is, and node document set to document.
-
~IF[ 次のいずれも満たされる ]…:
- %~ns ~EQ `~HTML~ns$
- [ %局所~名 は`妥当な~custom要素~名$である ]~OR[ %is ~NEQ ~NULL ]
…ならば ⇒ %結果 の`~custom要素~状態$ ~SET `undefined^l
◎ If namespace is the HTML namespace, and either localName is a valid custom element name or is is non-null, then set result’s custom element state to "undefined".
- ~RET %結果 ◎ Return result.
各`要素$は、 `属性o~list@ も持つ。 それは、`~list$であり, $NamedNodeMap 【~objを返す $attributes 属性】 を通して公開される。 `要素$の作成-時に明示的に与えられない限り,その`属性o~list$は`空$とする。 ◎ Elements also have an attribute list, which is a list exposed through a NamedNodeMap. Unless explicitly given when an element is created, its attribute list is empty.
`要素$ %要素 の`属性o~list$内に`属性o$ %属性o が在ることを, %要素 は %属性o を `有する@ ( `has^en )ともいう。 ◎ An element has an attribute A if its attribute list contains A.
【 この場合、[ %属性o が`属する要素$ ~EQ %要素 ]も満たすことになる — 複数の`要素$が同じ`属性o$を`有する$ことはない(~algo内で同期的に遂行される ある瞬間を除いて)。 】【 “有する” という句は、他の仕様(主に~HTML)で利用されている。 しかしながら,この訳では、この用語を(この仕様~内では)利用せず,一律に`属性o~list$(適用-可能な所では`属する要素$)を通して述べることにする。 】
`適用-可能な仕様$は、`要素$上の `属性o変更-時の手続き@ を定義してもヨイ。 この~algoは、当の要素に加えて, ( %局所~名, %旧-値, %値, %~ns ) を渡して呼出される。 ◎ This and other specifications may define attribute change steps for elements. The algorithm is passed element, localName, oldValue, value, and namespace.
`属性~変化を取扱う@ ときは、所与の ( `属性o$ %属性o, %要素, %旧-値, %新-値 ) に対し,次を走らす: ◎ To handle attribute changes for an attribute attribute with element, oldValue, and newValue, run these steps:
- %要素 用に種別 `attributes^l の`変異~記録を~queueする$( 次に挙げる引数 ) ⇒# %属性o の`局所~名$a, %属性o の`~ns$a, %旧-値, « », « », ~NULL, ~NULL ◎ Queue a mutation record of "attributes" for element with attribute’s local name, attribute’s namespace, oldValue, « », « », null, and null.
- ~IF[ %要素 は`~custom$である ] ⇒ `~custom要素~callback反応を~enqueueする$( %要素, `attributeChangedCallback^l, « %属性o の`局所~名$a, %旧-値, %新-値, %属性o の`~ns$ » ) ◎ If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute’s local name, oldValue, newValue, and attribute’s namespace.
- 次を渡して, %要素 上の`属性o変更-時の手続き$を走らす ⇒ ( %属性o の`局所~名$a, %旧-値, %新-値, %属性o の`~ns$a ) ◎ Run the attribute change steps with element, attribute’s local name, oldValue, newValue, and attribute’s namespace.
`属性oを変更する@ ときは、所与の ( `属性o$ %属性o, %値 ) に対し,次を走らす: ◎ To change an attribute attribute to value, run these steps:
- `属性~変化を取扱う$( %属性o, %属性o が`属する要素$, %属性o の`値$a, %値 ) ◎ Handle attribute changes for attribute with attribute’s element, attribute’s value, and value.
- %属性o の`値$a ~SET %値 ◎ Set attribute’s value to value.
`属性oを付加する@ ときは、所与の ( `属性o$ %属性o, `要素$ %要素 ) に対し,次を走らす: ◎ To append an attribute attribute to an element element, run these steps:
- `属性~変化を取扱う$( %属性o, %要素, ~NULL, %属性o の`値$a ) ◎ Handle attribute changes for attribute with element, null, and attribute’s value.
- %要素 の`属性o~list$に %属性o を`付加する$ ◎ Append attribute to element’s attribute list.
- %属性o が`属する要素$ ~SET %要素 ◎ Set attribute’s element to element.
`属性oを除去する@ ときは、所与の ( `属性o$ %属性o ) に対し,次を走らす: ◎ To remove an attribute attribute, run these steps:
- `属性~変化を取扱う$( %属性o, %属性o が`属する要素$, %属性o の`値$a, ~NULL ) ◎ Handle attribute changes for attribute with attribute’s element, attribute’s value, and null.
- %属性o が`属する要素$の`属性o~list$から %属性o を`除去する$ ◎ Remove attribute from attribute’s element’s attribute list.
- %属性o が`属する要素$ ~SET ~NULL ◎ Set attribute’s element to null.
`属性oを置換する@ ときは、所与の ( `属性o$ %旧-属性o, `属性o$ %新-属性o ) に対し,次を走らす: ◎ To replace an attribute oldAttr with an attribute newAttr, run these steps:
- `属性~変化を取扱う$( %旧-属性o, %旧-属性o が`属する要素$, %旧-属性o の`値$a, %新-属性o の`値$a ) ◎ Handle attribute changes for oldAttr with oldAttr’s element, oldAttr’s value, and newAttr’s value.
- %旧-属性o が`属する要素$の`属性o~list$内で, %旧-属性o を %新-属性o に`置換する$ ◎ Replace oldAttr by newAttr in oldAttr’s element’s attribute list.
- %新-属性o が`属する要素$ ~SET %旧-属性o が`属する要素$ ◎ Set newAttr’s element to oldAttr’s element.
- %旧-属性o が`属する要素$ ~SET ~NULL ◎ Set oldAttr’s element to null.
`要素$ %要素 の `属性oを名前により取得する@ ときは、所与の ( %有修飾~名 ) に対し,次を走らす: ◎ To get an attribute by name given a qualifiedName and element element, run these steps:
- ~IF[ %要素 は`~HTML~ns$に属する ]~AND[ %要素 の`~node文書$は`~HTML文書$である ] ⇒ %有修飾~名 ~LET `~ASCII小文字~化する$( %有修飾~名 ) ◎ If element is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
- ~RET %要素 の`属性o~list$ 内の次を満たす`属性o$のうち,`最初のもの?$ ⇒ `有修飾~名$a ~EQ %有修飾~名 ◎ Return the first attribute in element’s attribute list whose qualified name is qualifiedName, and null otherwise.
`要素$ %要素 の `属性oを~nsと局所~名により取得する@ ときは、所与の ( %~ns, %局所~名 ) に対し、次を走らす: ◎ To get an attribute by namespace and local name given a namespace, localName, and element element, run these steps:
- ~RET %要素 の`属性o~list$ 内の 次を満たす`属性o$のうち,`最初のもの?$ ⇒ [ `~ns$a ~EQ %~ns ]~AND[ `局所~名$a ~EQ %局所~名 ] ◎ Return the attribute in element’s attribute list whose namespace is namespace and local name is localName, if any, and null otherwise.
`要素$ %要素 の `属性o値を取得する@ ときは、所与の ( %局所~名, %~ns (省略時は ~NULL ) ) に対し,次を走らす: ◎ To get an attribute value given an element element, localName, and optionally a namespace (null unless stated otherwise), run these steps:
- %属性o ~LET %要素 の`属性oを~nsと局所~名により取得する$( %局所~名, %~ns ) ◎ Let attr be the result of getting an attribute given namespace, localName, and element.
- ~RET [ %属性o ~EQ ~NULL ならば空~文字列 / ~ELSE_ %属性o の`値$a ] ◎ If attr is null, then return the empty string. ◎ Return attr’s value.
`要素$ %要素 の `属性oを設定する@ ときは、所与の ( `属性o$ %属性o ) に対し,次を走らす: ◎ To set an attribute given an attr and element, run these steps:
- ~IF[ %属性o が`属する要素$ ~NIN { ~NULL, %要素 } ] ⇒ ~THROW `InUseAttributeError$E ◎ If attr’s element is neither null nor element, throw an "InUseAttributeError" DOMException.
- %旧-属性o ~LET %要素 の`属性oを~nsと局所~名により取得する$( %属性o の`~ns$a, %属性o の`局所~名$a ) ◎ Let oldAttr be the result of getting an attribute given attr’s namespace, attr’s local name, and element.
- ~IF[ %旧-属性o ~EQ %属性o ] ⇒ ~RET %属性o ◎ If oldAttr is attr, return attr.
- ~IF[ %旧-属性o ~NEQ ~NULL ] ⇒ `属性oを置換する$( %旧-属性o, %属性o ) ◎ If oldAttr is non-null, then replace oldAttr with attr.
- ~ELSE ⇒ `属性oを付加する$( %属性o, %要素 ) ◎ Otherwise, append attr to element.
- ~RET %旧-属性o ◎ Return oldAttr.
`要素$ %要素 の `属性o値を設定する@ ときは、所与の ( %局所~名, %値, %接頭辞 (省略時は ~NULL ), %~ns (省略時は ~NULL ) ) に対し,次を走らす: ◎ To set an attribute value for an element element, using a localName and value, and an optional prefix, and namespace, run these steps:
- %属性o ~LET %要素 の`属性oを~nsと局所~名により取得する$( %~ns, %局所~名 ) ◎ If prefix is not given, set it to null. ◎ If namespace is not given, set it to null. ◎ Let attribute be the result of getting an attribute given namespace, localName, and element.
- ~IF[ %属性o ~NEQ ~NULL ] ⇒# `属性oを変更する$( %属性o, %値 ); ~RET ◎ ↓
- `属性oを付加する$( 次のように設定された新たな`属性o$, %要素 ) ⇒# `~ns$a ~SET %~ns, `~ns接頭辞$a ~SET %接頭辞, `局所~名$a ~SET %局所~名, `値$a ~SET %値, `~node文書$ ~SET %要素 の`~node文書$ ◎ If attribute is null, create an attribute whose namespace is namespace, namespace prefix is prefix, local name is localName, value is value, and node document is element’s node document, then append this attribute to element, and then return. ◎ Change attribute to value.
`要素$ %要素 の `属性oを名前により除去する@ ときは、所与の ( %有修飾~名 ) に対し,次を走らす: ◎ To remove an attribute by name given a qualifiedName and element element, run these steps:
- %属性o ~LET %要素 の`属性oを名前により取得する$( %有修飾~名 ) ◎ Let attr be the result of getting an attribute given qualifiedName and element.
- ~IF[ %属性o ~NEQ ~NULL ] ⇒ `属性oを除去する$( %属性o ) ◎ If attr is non-null, then remove attr.
- ~RET %属性o ◎ Return attr.
`要素$ %要素 の `属性oを~nsと局所~名により除去する@ ときは、所与の ( %~ns, %局所~名 ) に対し,次を走らす: ◎ To remove an attribute by namespace and local name given a namespace, localName, and element element, run these steps:
- %属性o ~LET %要素 の`属性oを~nsと局所~名により取得する$( %~ns, %局所~名 ) ◎ Let attr be the result of getting an attribute given namespace, localName, and element.
- ~IF[ %属性o ~NEQ ~NULL ] ⇒ `属性oを除去する$( %属性o ) ◎ If attr is non-null, then remove attr.
- ~RET %属性o ◎ Return attr.
`要素$には、一意な識別子である `~ID@ が結付けられ得る。 ◎ An element can have an associated unique identifier (ID)
注記: 歴史的に,`要素$は複数の識別子を持ち得ていた。 例えば~HTML `id^A `属性o$nmと DTD を利用して。 この仕様では `~ID$を~DOMの概念とし,`要素$につき `id^A `属性o$nmで与えられる 1 個に限るとする。 ◎ Historically elements could have multiple identifiers e.g., by using the HTML id attribute and a DTD. This specification makes ID a concept of the DOM and allows for only one per element, given by an id attribute.
`要素$の`~ID$の更新~時に利用する,`属性o変更-時の手続き$は、次で与えられる: ◎ Use these attribute change steps to update an element’s ID:
- ~IF[ %局所~名 ~EQ `id^l ]~AND[ %~ns ~EQ ~NULL ]~AND[ %値 ~IN { ~NULL, 空~文字列 } ] ⇒ %要素 の`~ID$を未設定にする ◎ If localName is id, namespace is null, and value is null or the empty string, then unset element’s ID.
- ~ELIF[ %局所~名 ~EQ `id^l ]~AND[ %~ns ~EQ ~NULL ] ⇒ %要素 の`~ID$ ~SET %値 ◎ Otherwise, if localName is id, namespace is null, then set element’s ID to value.
注記: この仕様は、どの`要素$に対しても,その[ `id^A / `class^A / `slot^A ]`属性o$nm用の要件を定義しているが、これらの属性oを利用をするかどうかは,適合性の要件にしていない。 ◎ While this specification defines requirements for class, id, and slot attributes on any element, it makes no claims as to whether using them is conforming or not.
`~node$ %N の `親~要素@ とは、[ %N の`親$が`要素$であるならば それ / ~ELSE_ ~NULL ]である。 ◎ A node’s parent of type Element is known as a parent element. If the node has a parent of a different type, its parent element is null.
- %namespace = %element . $namespaceURI
- `~ns$を返す。 ◎ Returns the namespace.
- %prefix = %element . $prefix
- `~ns接頭辞$を返す。 ◎ Returns the namespace prefix.
- %localName = %element . $localName
- `局所~名$を返す。 ◎ Returns the local name.
- %qualifiedName = %element . $tagName
- `~HTML大文字~化~有修飾~名$を返す。 ◎ Returns the HTML-uppercased qualified name.
- %element . $id [ = %value ]
- %element の `id^A 属性oの値を返す。 設定して変更できる。 ◎ Returns the value of element’s id content attribute. Can be set to change it.
- %element . $className [ = %value ]
- %element の `class^A 属性oの値を返す。 設定して変更できる。 ◎ Returns the value of element’s class content attribute. Can be set to change it.
- %element . $classList
- %element の `class^A 属性oを,空白~区切り~tokenの集合として — $DOMTokenList ~objを通して — 操作できるようにする。 ◎ Allows for manipulation of element’s class content attribute as a set of whitespace-separated tokens through a DOMTokenList object.
- %element . $slot [ = %value ]
- %element の `slot^A 属性oを返す。 設定して変更できる。 ◎ Returns the value of element’s slot content attribute. Can be set to change it.
`要素$ %要素 上の一部の~IDL属性は、所与の %名前 の`属性o$を `反映する@ ように定義される。 すなわち、次に従うような取得子, 設定子を持つモノトスル: ◎ IDL attributes that are defined to reflect a content attribute of a given name, must have a getter and setter that follow these steps:
- 取得子
- ~RET %要素 の`属性o値を取得する$( %名前 ) ◎ Return the result of running get an attribute value given this and name.
- 設定子
- %要素 の`属性o値を設定する$( %名前, 所与の値 ) ◎ Set an attribute value for this using name and the given value.
@id 属性は、 `id^l 属性oを`反映する$モノトスル。 ◎ The id attribute must reflect the "id" content attribute.
@className 属性は、 `class^l 属性oを`反映する$モノトスル。 ◎ The className attribute must reflect the "class" content attribute.
@classList 取得子~手続きは ⇒ ~RET 次のように設定された $DOMTokenList ⇒# `要素$tL ~SET コレ, `属性oの局所~名$tL ~SET ^class ◎ The classList attribute’s getter must return a DOMTokenList object whose associated element is this and whose associated attribute’s local name is class.\
この取得子が返す $DOMTokenList ~objの`~token集合$tLは、`要素$の `~classes@ とも称される。 ◎ The token set of this particular DOMTokenList object are also known as the element’s classes.
【 [`SameObject$] が指定されているので、各~要素とこの~objの各~instanceは,一対一に対応する。 】
@slot 属性は、 `slot^l 属性oを`反映する$モノトスル。 ◎ The slot attribute must reflect the "slot" content attribute.
注記: [ `id^A / `class^A / `slot^A ]`属性o$nmは、要素の~nsにかかわらず どの要素~上にも現れ得るので、実質的に,(すべての~nsより)上位の大域~属性になる。 ◎ id, class, and slot are effectively superglobal attributes as they can appear on any element, regardless of that element’s namespace.
- %element . $hasAttributes()
- %element の`属性o~list$は[ 空でないならば ~T / 空ならば ~F ]を返す。 ◎ Returns true if element has attributes, and false otherwise.
- %element . $getAttributeNames()
- %element のすべての`属性o$の`有修飾~名$aを返す — 重複を包含し得る。 ◎ Returns the qualified names of all element’s attributes. Can contain duplicates.
- %element . $getAttribute(qualifiedName)
- %element の`属性o~list$内の`属性o$のうち次を満たす`最初のもの?$を返す ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Returns element’s first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.
- %element . $getAttributeNS(namespace, localName)
- %element の`属性o~list$内の`属性o$のうち次を満たす`最初のもの?$を返す ⇒ [ `~ns$a ~EQ %namespace ]~AND[ `局所~名$a ~EQ %localName ] ◎ Returns element’s attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise.
- %element . $setAttribute(qualifiedName, value)
- %element の`属性o~list$内に次を満たす`属性o$が在るならば[ それらのうち最初のもの ]の`値$aを %value に設定する ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Sets the value of element’s first attribute whose qualified name is qualifiedName to value.
- %element . $setAttributeNS(namespace, localName, value)
- %element の`属性o~list$内に次を満たす`属性o$が在るならば[ それらのうち最初のもの ]の`値$aを %value に設定する ⇒ [ `~ns$a ~EQ %namespace ]~AND[ `局所~名$a ~EQ %localName ] ◎ Sets the value of element’s attribute whose namespace is namespace and local name is localName to value.
- %element . $removeAttribute(qualifiedName)
- %element の`属性o~list$内に次を満たす`属性o$が在るならば[ それらのうち最初のもの ]を %element から除去する ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Removes element’s first attribute whose qualified name is qualifiedName.
- %element . $removeAttributeNS(namespace, localName)
- %element の`属性o~list$内に次を満たす`属性o$が在るならば[ それらのうち最初のもの ]を %element から除去する ⇒ [ `~ns$a ~EQ %namespace ]~AND[ `局所~名$a ~EQ %localName ] ◎ Removes element’s attribute whose namespace is namespace and local name is localName.
- %element . $toggleAttribute(qualifiedName [, force])
-
%force に応じて:
- 省略されているならば、 %qualifiedName の有無を “切り替える” — すなわち,それがすでに在れば除去し,無ければ追加する。
- ~T ならば、 %qualifiedName を追加する。
- ~F ならば、 %qualifiedName を除去する。
その結果、 %qualifiedName が残っていれば ~T を, 無くなっていれば ~F を返す。
◎ If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName. ◎ Returns true if qualifiedName is now present, and false otherwise. - %element . $hasAttribute(qualifiedName)
- %element の`属性o~list$内に次を満たす`属性o$が[ 在るならば ~T / 無いならば ~F ]を返す ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise.
- %element . $hasAttributeNS(namespace, localName)
- %element の`属性o~list$内に次を満たす`属性o$が[ 在るならば ~T / 無いならば ~F ]を返す ⇒ [ `~ns$a ~EQ %namespace ]~AND[ `局所~名$a ~EQ %localName ] ◎ Returns true if element has an attribute whose namespace is namespace and local name is localName.
@getAttributeNames() ~method~手続きは ⇒ ~RET コレの`属性o~list$ %~list は[ `空$でないならば[ %~list 内の各 `属性o$の`有修飾~名$a ]からなる同じ順序の`~list$ / ~ELSE_ 新たな`~list$ ] ◎ The getAttributeNames() method, when invoked, must return the qualified names of the attributes in this’s attribute list, in order, and a new list otherwise.
注記: 一意になることは保証されない。 ◎ These are not guaranteed to be unique.
@getAttribute(qualifiedName) ~method~手続きは: ◎ The getAttribute(qualifiedName) method, when invoked, must run these steps:
- %属性o ~LET コレの`属性oを名前により取得する$( %qualifiedName ) ◎ Let attr be the result of getting an attribute given qualifiedName and this.
- ~RET [ %属性o ~EQ ~NULL ならば ~NULL / ~ELSE_ %属性o の`値$a ] ◎ If attr is null, return null. ◎ Return attr’s value.
@getAttributeNS(namespace, localName) ~method~手続きは: ◎ The getAttributeNS(namespace, localName) method, when invoked, must these steps:
- %属性o ~LET コレの`属性oを~nsと局所~名により取得する$( %namespace, %localName ) ◎ Let attr be the result of getting an attribute given namespace, localName, and this.
- ~IF[ %属性o ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If attr is null, return null.
- ~RET %属性o の`値$a ◎ Return attr’s value.
@setAttribute(qualifiedName, value) ~method~手続きは: ◎ The setAttribute(qualifiedName, value) method, when invoked, must run these steps:
- ~IF[ %qualifiedName は~XMLの `Name$prod 生成規則に合致しない ] ⇒ ~THROW `InvalidCharacterError$E ◎ If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
- ~IF[ コレは`~HTML~ns$に属する ]~AND[ コレの`~node文書$は`~HTML文書$である ] ⇒ %qualifiedName ~SET `~ASCII小文字~化する$( %qualifiedName ) ◎ If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
- %属性o ~LET コレの`属性o~list$内に在る`属性o$のうち,次を満たす`最初のもの?$ ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Let attribute be the first attribute in this’s attribute list whose qualified name is qualifiedName, and null otherwise.
- ~IF[ %属性o ~EQ ~NULL ] ⇒ `属性oを付加する$( 次のように設定された新たな`属性o$, コレ ) ⇒# `局所~名$a ~SET %qualifiedName, `値$a ~SET %value, `~node文書$ ~SET コレの`~node文書$ ◎ If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document is this’s node document, then append this attribute to this, and then return.
- ~ELSE ⇒ `属性oを変更する$( %属性o, %value ) ◎ Change attribute to value.
@setAttributeNS(namespace, qualifiedName, value) ~method~手続きは: ◎ The setAttributeNS(namespace, qualifiedName, value) method, when invoked, must run these steps:
- コレの`属性o値を設定する$( %局所~名, %value, %接頭辞, %~ns ) ◎ Set an attribute value for this using localName, value, and also prefix and namespace.
@hasAttribute(qualifiedName) ~method~手続きは: ◎ The hasAttribute(qualifiedName) method, when invoked, must run these steps:
- ~RET [ コレの`属性o~list$内に次を満たす`属性o$が在るならば ~T / ~ELSE_ ~F ] ⇒ `有修飾~名$a ~EQ %qualifiedName ◎ Return true if this has an attribute whose qualified name is qualifiedName, and false otherwise.
@toggleAttribute(qualifiedName, force) ~method~手続きは: ◎ The toggleAttribute(qualifiedName, force) method, when invoked, must run these steps:
- %結果 ~LET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ [ %force ~EQ ~T ]~OR[[ %force は与えられてない ]~AND[ %属性o ~EQ ~NULL ]] ◎ ↓
- ~IF[ %結果 ~EQ ~T ]~AND[ %属性o ~EQ ~NULL ] ⇒ `属性oを付加する$( 次のように設定された新たな`属性o$, コレ ) ⇒# `局所~名$a ~SET %qualifiedName, `値$a ~SET 空~文字列, `~node文書$ ~SET コレの`~node文書$ ◎ If attribute is null, then: • If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this’s node document, then append this attribute to this, and then return true. • Return false.
- ~ELIF[ %結果 ~EQ ~F ]~AND[ %属性o ~NEQ ~NULL ] ⇒# コレの`属性oを名前により除去する$( %qualifiedName ); ◎ Otherwise, if force is not given or is false, remove an attribute given qualifiedName and this, and then return false.
- ~RET %結果 ◎ Return true.
@hasAttributeNS(namespace, localName) ~method~手続きは: ◎ The hasAttributeNS(namespace, localName) method, when invoked, must run these steps:
- ~RET [ コレの`属性o~list$内に次を満たす`属性o$が在るならば ~T / ~ELSE_ ~F ] ⇒ [ `~ns$a ~EQ %namespace ]~AND[ `局所~名$a ~EQ %localName ] ◎ Return true if this has an attribute whose namespace is namespace and local name is localName, and false otherwise.
@removeAttributeNode(attr) ~method~手続きは: ◎ The removeAttributeNode(attr) method, when invoked, must run these steps:
- ~IF[ %attr ~NIN コレの`属性o~list$ ] ⇒ ~THROW `NotFoundError$E ◎ If this’s attribute list does not contain attr, then throw a "NotFoundError" DOMException.
- `属性oを除去する$( %attr ) ◎ Remove attr.
- ~RET %attr ◎ Return attr.
- %shadow = %element . $attachShadow(init)
- %element 用に`~shadow根$を作成した上で,それを返す。 ◎ Creates a shadow root for element and returns it.
- %shadow = %element . $shadowRoot
- %element の`~shadow根$elm %~shadow は非~NULL,かつ %~shadow の[ `~mode$sR ~EQ `open^l ]ならば %~shadow を返す。 他の場合は ~NULL を返す。 ◎ Returns element’s shadow root, if any, and if shadow root’s mode is "open", and null otherwise.
@attachShadow(init) ~method~手続きは: ◎ The attachShadow(init) method, when invoked, must run these steps:
- ~IF[ コレの`~ns$ ~NEQ `~HTML~ns$ ] ⇒ ~THROW `NotSupportedError$E ◎ If this’s namespace is not the HTML namespace, then throw a "NotSupportedError" DOMException.
-
~IF[ コレの`局所~名$は 次のいずれでもない ]…: ◎ If this’s local name is not one of the following:
- `妥当な~custom要素~名$ ◎ a valid custom element name
- `article^l, `aside^l, `blockquote^l, `body^l, `div^l, `footer^l, `h1^l, `h2^l, `h3^l, `h4^l, `h5^l, `h6^l, `header^l, `main^l, `nav^l, `p^l, `section^l, `span^l ◎ "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main", "nav", "p", "section", or "span"
…ならば ⇒ ~THROW `NotSupportedError$E ◎ then throw a "NotSupportedError" DOMException.
-
~IF[ コレの`局所~名$は`妥当な~custom要素~名$である ]~OR[ コレの`~is0値$ ~NEQ ~NULL ]: ◎ If this’s local name is a valid custom element name, or this’s is value is not null, then:
- %定義 ~LET `~custom要素~定義を検索する$( コレの`~node文書$, コレの`~ns$, コレの`局所~名$, コレの`~is0値$ ) ◎ Let definition be the result of looking up a custom element definition given this’s node document, its namespace, its local name, and its is value.
- ~IF[ %定義 ~NEQ ~NULL ]~AND[ %定義 の`~shadowを不能化する$cD ~EQ ~T ] ⇒ ~THROW `NotSupportedError$E ◎ If definition is not null and definition’s disable shadow is true, then throw a "NotSupportedError" DOMException.
- ~IF[ コレは`~shadow~host$である ] ⇒ ~THROW `NotSupportedError$E ◎ If this is a shadow host, then throw an "NotSupportedError" DOMException.
- %~shadow ~LET 次のように設定された新たな`~shadow根$ ⇒# `~node文書$ ~SET コレの`~node文書$, `~host$ ~SET コレ, `~mode$sR ~SET %init[ "$ShadowRootInit.mode" ] ◎ Let shadow be a new shadow root whose node document is this’s node document, host is this, and mode is init’s mode.
- %~shadow の`~focusを委譲する$sR ~SET %init[ "$ShadowRootInit.delegatesFocus" ] ◎ Set shadow’s delegates focus to init’s delegatesFocus.
- ~IF[ コレの`~custom要素~状態$ ~IN { `precustomized^l, `custom^l } ] ⇒ %~shadow の`要素の内部特能から可用$sR ~SET ~T ◎ If this’s custom element state is "precustomized" or "custom", then set shadow’s available to element internals to true.
- コレの`~shadow根$elm ~SET %~shadow ◎ Set this’s shadow root to shadow.
- ~RET %~shadow ◎ Return shadow.
@shadowRoot 取得子~手続きは: ◎ The shadowRoot attribute’s getter must run these steps:
- %~shadow ~LET コレの `~shadow根$elm ◎ Let shadow be this’s shadow root.
- ~IF[ %~shadow ~EQ ~NULL ]~OR[ %~shadow の`~mode$sR ~EQ `closed^l ] ⇒ ~RET ~NULL ◎ If shadow is null or its mode is "closed", then return null.
- ~RET %~shadow ◎ Return shadow.
- %element . $closest(selectors)
- %element の`広義先祖$であって, %selectors に合致するような`要素$が[ 在れば,それらのうち %element に最も近いもの / 無ければ ~NULL ]を返す。 ◎ Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.
- %element . $matches(selectors)
- %element の`根$に対し %selectors を照合した結果,[ %element が得られるならば ~T / ~ELSE_ ~F ]を返す。 ◎ Returns true if matching selectors against element’s root yields element, and false otherwise.
@closest(selectors) ~method~手続きは: ◎ The closest(selectors) method, when invoked, must run these steps:
- %選択子 ~LET `選択子として構文解析する$( %selectors ) `SELECTORS4$r ◎ Let s be the result of parse a selector from selectors. [SELECTORS4]
- ~IF[ %選択子 ~EQ `失敗^i ] ⇒ ~THROW `SyntaxError$E ◎ If s is failure, throw a "SyntaxError" DOMException.
- %要素 ~LET コレ ◎ ↓
-
~WHILE[ %要素 は`要素$である ]:
- ~IF[ `要素に対し選択子を照合する$( %要素, %選択子, コレのみからなる`~scope-ps要素$の集合 ) ~EQ `成功^i ] ⇒ ~RET %要素
- %要素 ~SET %要素 の`親$
- ~RET ~NULL ◎ Return null.
@matches(selectors), @webkitMatchesSelector(selectors) ~method~手続きは、いずれも: ◎ The matches(selectors) and webkitMatchesSelector(selectors) method steps are:
- %選択子 ~LET `選択子として構文解析する$( %selectors ) `SELECTORS4$r ◎ Let s be the result of parse a selector from selectors. [SELECTORS4]
- ~IF[ %選択子 ~EQ `失敗^i ] ⇒ ~THROW `SyntaxError$E ◎ If s is failure, then throw a "SyntaxError" DOMException.
- ~RET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ `要素に対し選択子を照合する$( コレ, %選択子, コレのみからなる`~scope-ps要素$の集合 ) ~EQ `成功^i `SELECTORS4$r ◎ If the result of match a selector against an element, using s, this, and :scope element this, returns success, then return true; otherwise, return false. [SELECTORS4]
`要素$ %要素 の `隣に~nodeを挿入する@ ときは、所与の ( 文字列 %where, `~node$ %~node ) に対し, `~ASCII小文字~化する$( %where ) の結果に応じて: ◎ To insert adjacent, given an element element, string where, and a node node, run the steps associated with the first ASCII case-insensitive match for where:
- `beforebegin^l
-
- ~IF[ %要素 の`親$ ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If element’s parent is null, return null.
- ~RET %要素 の`親$の中で`~nodeを子の前に前挿入する$( %~node, %要素 ) ◎ Return the result of pre-inserting node into element’s parent before element.
- `afterbegin^l
-
- ~RET %要素 の中で`~nodeを子の前に前挿入する$( %~node, %要素 の`最初の子?$ ) ◎ Return the result of pre-inserting node into element before element’s first child.
- `beforeend^l
-
- ~RET %要素 の中で`~nodeを子の前に前挿入する$( %~node, ~NULL ) ◎ Return the result of pre-inserting node into element before null.
- `afterend^l
-
- ~IF[ %要素 の`親$ ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If element’s parent is null, return null.
- ~RET %要素 の`親$の中で`~nodeを子の前に前挿入する$( %~node, %要素 の`次-同胞?$ ) ◎ Return the result of pre-inserting node into element’s parent before element’s next sibling.
- その他
-
- ~THROW `SyntaxError$E ◎ Throw a "SyntaxError" DOMException.
@insertAdjacentText(where, data) ~method~手続きは: ◎ The insertAdjacentText(where, data) method, when invoked, must run these steps:
- %text ~LET `新たな~Text~node$( %data, コレの`~node文書$ ) ◎ Let text be a new Text node whose data is data and node document is this’s node document.
- コレの`隣に~nodeを挿入する$( %where, %text ) ◎ Run insert adjacent, given this, where, and text.
注記: この~methodは何も返さない — それを設計しようとする前からすでに存在していたので。 ◎ This method returns nothing because it existed before we had a chance to design it.
【 参考: `insertAdjacentHTML()$m `DOM-Parsing$r という同類の便利~methodもある。 】
4.9.1. ^@NamedNodeMap ~interface
!! [`Exposed$=Window, `LegacyUnenumerableNamedProperties$] interface @NamedNodeMap { ~RA `unsigned long$ $length; getter $Attr? $item(`unsigned long$ %index); getter $Attr? $getNamedItem($DOMString %qualifiedName); $Attr? $getNamedItemNS($DOMString? %namespace, $DOMString %localName); [`CEReactions$] $Attr? $setNamedItem($Attr %attr); [`CEReactions$] $Attr? $setNamedItemNS($Attr %attr); [`CEReactions$] $Attr $removeNamedItem($DOMString %qualifiedName); [`CEReactions$] $Attr $removeNamedItemNS($DOMString? %namespace, $DOMString %localName); }; !各 $NamedNodeMap ~objには、次に挙げるものが結付けられる:
- `要素@nm
- `要素$。
$NamedNodeMap ~objの `属性o~list@nm とは、~objの`要素$nmの`属性o~list$である。 ◎ A NamedNodeMap object’s attribute list is its element’s attribute list.
$NamedNodeMap ~obj %O が`~supportする~prop~index$は、 0 以上[ %O の`属性o~list$nmの`~size$ ]未満とする。 ◎ A NamedNodeMap object’s supported property indices are the numbers in the range zero to its attribute list’s size minus one, unless the attribute list is empty, in which case there are no supported property indices.
$NamedNodeMap ~obj %O が`~supportする~prop名$たちは、次の手続きの結果で与えられる: ◎ A NamedNodeMap object’s supported property names are the return value of running these steps:
- %名前~list ~LET %O の`属性o~list$nm 内の各[ `属性o$の`有修飾~名$a ]からなる,同順の~list ◎ Let names be the qualified names of the attributes in this NamedNodeMap object’s attribute list, with duplicates omitted, in order.
- %要素 ~LET %O の`要素$nm ◎ ↓
- ~IF[ %要素 は`~HTML~ns$に属する ]~AND[ %要素 の`~node文書$は`~HTML文書$である ] ⇒ %名前~list 内の ~EACH( %名前 ) に対し ⇒ ~IF[ `~ASCII小文字~化する$( %名前 ) ~NEQ %名前 ] ⇒ %名前 を %名前~list から除去する ◎ If this NamedNodeMap object’s element is in the HTML namespace and its node document is an HTML document, then for each name in names: • Let lowercaseName be name, in ASCII lowercase. • If lowercaseName is not equal to name, remove name from names.
- ~RET %名前~list ◎ Return names.
@removeNamedItem(qualifiedName) ~method~手続きは: ◎ The removeNamedItem(qualifiedName) method, when invoked, must run these steps:
- %属性o ~LET コレの`要素$nmの`属性oを名前により除去する$( %qualifiedName ) ◎ Let attr be the result of removing an attribute given qualifiedName and element.
- ~IF[ %属性o ~EQ ~NULL ] ⇒ ~THROW `NotFoundError$E ◎ If attr is null, then throw a "NotFoundError" DOMException.
- ~RET %属性o ◎ Return attr.
@removeNamedItemNS(namespace, localName) ~method~手続きは: ◎ The removeNamedItemNS(namespace, localName) method, when invoked, must run these steps:
- %属性o ~LET コレの`要素$nmの`属性oを~nsと局所~名により除去する$( %namespace, %localName ) ◎ Let attr be the result of removing an attribute given namespace, localName, and element.
- ~IF[ %属性o ~EQ ~NULL ] ⇒ ~THROW `NotFoundError$E ◎ If attr is null, then throw a "NotFoundError" DOMException.
- ~RET %属性o ◎ Return attr.
4.9.2. ^@Attr ~interface
!! [`Exposed$=Window] interface @Attr : $Node { ~RA $DOMString? $namespaceURI; ~RA $DOMString? $prefix; ~RA $DOMString $localName; ~RA $DOMString $name; [`CEReactions$] attribute $DOMString $value; ~RA Element? $ownerElement; ~RA $boolean $specified; // }; !$Attr `~node$は、単に `属性o@ ( `attribute^en )とも称される — ~IDL属性と区別するため、内容~属性とも称される。 【この訳では, “°” を付けて “属性o” と記すことにする。】 ◎ Attr nodes are simply known as attributes. They are sometimes referred to as content attributes to avoid confusion with IDL attributes.
各 `属性o$は、次に挙げるものを持つ:
- `~ns@a
- ~NULL または 空でない文字列
- `~ns接頭辞@a
- ~NULL または 空でない文字列
- `局所~名@a
- 空でない文字列
- `値@a
- 文字列
- `属する要素@
- ~NULL または`要素$ 【 ~NULL でないならば、属性oは要素の`属性o~list$内に在ることになる。】
注記: 今 設計するなら、単に[ 名前, 値 ]のみを持つ様にする所 ☹ ◎ If designed today they would just have a name and value. ☹
`属性o$ %A の `有修飾~名@a は、 %A の`~ns接頭辞$a %接頭辞 に応じて,[ ~NULL ならば %A の`局所~名$a / 非 ~NULL ならば[ %接頭辞, `:^l, %A の`局所~名$a ]の並び ]になる。 ◎ An attribute’s qualified name is its local name if its namespace prefix is null, and its namespace prefix, followed by ":", followed by its local name, otherwise.
注記: ~UAは、これを内部~slotに持たせて最適化することもできる。 ◎ User agents could have this as an internal slot as an optimization.
`属性o$が作成されるときは、その`局所~名$aが与えられる。 `属性o$の作成-時に明示的に与えられない限り,他のものは次のように設定される ⇒ ( `~ns$a, `~ns接頭辞$a, `属する要素$, `値$a ) ~SET ( ~NULL, ~NULL, ~NULL, 空~文字列 ) ◎ When an attribute is created, its local name is given. Unless explicitly given when an attribute is created, its namespace, namespace prefix, and element are set to null, and its value is set to the empty string.
文字列 %A に対する %A 属性o という~~表記は、次を満たす `属性o$を意味する ⇒ ( `局所~名$a, `~ns$a, `~ns接頭辞$a ) ~EQ ( %A, ~NULL, ~NULL ) ◎ An A attribute is an attribute whose local name is A and whose namespace and namespace prefix are null.
`既存の属性o値を設定する@ ときは、所与の ( `属性o$ %属性o, 文字列 %値 ) に対し,次を走らす: ◎ To set an existing attribute value, given an attribute attribute and string value, run these steps:
- ~IF[ %属性o が`属する要素$ ~EQ ~NULL ] ⇒ %属性o の`値$a ~SET %値 ◎ If attribute’s element is null, then set attribute’s value to value.
- ~ELSE ⇒ `属性oを変更する$( %属性o, %値 ) ◎ Otherwise, change attribute to value.
4.10. ^@CharacterData ~interface
!! [`Exposed$=Window] interface @CharacterData : $Node { attribute [`LegacyNullToEmptyString$] $DOMString $data; ~RA `unsigned long$ $length; $DOMString $substringData(`unsigned long$ %offset, `unsigned long$ %count); $undefined $appendData($DOMString %data); $undefined $insertData(`unsigned long$ %offset, $DOMString %data); $undefined $deleteData(`unsigned long$ %offset, `unsigned long$ %count); $undefined $replaceData(`unsigned long$ %offset, `unsigned long$ %count, $DOMString %data); }; !注記: $CharacterData は抽象-~interfaceであり,`~node$として存在するものではない。 それは[ $Text, $ProcessingInstruction, $Comment ]`~node$から利用される。 ◎ CharacterData is an abstract interface and does not exist as node. It is used by Text, ProcessingInstruction, and Comment nodes.
この~interfaceを実装する`~node$を総称して, `文字~data~node@ という(すなわち, $Text ( $CDATASection も含む), $ProcessingInstruction, $Comment )。
【 この用語は、簡潔に記述するために,この訳に導入した非公式な用語である。 (機能上は異なるものだが)多くの処理で,これらは同等に扱われるので。 】
各 `文字~data~node$には、次に挙げるものが結付けられる:
- `~data@
- 変異-可能な文字列。
`文字~data~node$ %node の `~dataを置換する@ ときは、所与の ( %offset, %count, %data ) に対し,次を走らす: ◎ To replace data of node node with offset offset, count count, and data data, run these steps:
- %長さ ~LET %node の`長さ$ ◎ Let length be node’s length.
- ~IF[ %offset ~GT %長さ ] ⇒ ~THROW `IndexSizeError$E ◎ If offset is greater than length, then throw an "IndexSizeError" DOMException.
- ~IF[ %offset ~PLUS %count ~GT %長さ ] ⇒ %count ~SET %長さ ~MINUS %offset ◎ If offset plus count is greater than length, then set count to length minus offset.
- %node 用に種別 `characterData^l の`変異~記録を~queueする$( 次に挙げる引数 ) ⇒# ~NULL, ~NULL, %node の`~data$, « », « », ~NULL, ~NULL ◎ Queue a mutation record of "characterData" for node with null, null, node’s data, « », « », null, and null.
- %挿入点 ~LET %node の`~data$の中で, %offset 個目の`符号単位$の直後を指す位置( %offset ~EQ 0 は先頭を指す) ◎ ↓
- %挿入点 から末尾側に在る %count 個の`符号単位$を除去する ◎ ↓
- %挿入点 に %data を挿入する ◎ Insert data into node’s data after offset code units. ◎ Let delete offset be offset + data’s length. ◎ Starting from delete offset code units, remove count code units from node’s data.
- %差分 ~LET %data の`長さ$str ~MINUS %count ◎ ↓
-
~EACH( `~live範囲o$ %範囲o ) に対し:
-
~IF[ %範囲o の`始端~node$ ~EQ %node ]:
- ~IF[ %offset ~LT %範囲o の`始端~offset$ ~LTE %offset ~PLUS %count ] ⇒ %範囲o の`始端~offset$ ~SET %offset
- ~IF[ %範囲o の`始端~offset$ ~GT %offset ~PLUS %count ] ⇒ %範囲o の`始端~offset$ ~INCBY %差分
-
~IF[ %範囲o の`終端~node$ ~EQ %node ]:
-
~IF[ %offset ~LT %範囲o の`終端~offset$ ~LTE %offset ~PLUS %count ] ⇒ %範囲o の`終端~offset$ ~SET %offset
【 %範囲o の終端がちょうど置換される~~範囲の末尾を指している場合も,終端は置換した~~範囲の先頭に “寄せられる” ことになる。 】
- ~IF[ %範囲o の`終端~offset$ ~GT %offset ~PLUS %count ] ⇒ %範囲o の`終端~offset$ ~INCBY %差分
-
-
- ~IF[ %node の`親$ ~NEQ ~NULL ] ⇒ %node の`親$用の`子たち変更-時の手続き$を走らす ◎ If node’s parent is non-null, then run the children changed steps for node’s parent.
`文字~data~node$ %node から `~dataの部分文字列@ を得るときは、所与の ( %offset, %count ) に対し,次を走らす: ◎ To substring data with node node, offset offset, and count count, run these steps:
- ~IF[ %offset ~PLUS %count ~GT %長さ ] ⇒ %count ~LET %長さ ~MINUS %offset ◎ If offset plus count is greater than length, return a string whose value is the code units from the offsetth code unit to the end of node’s data, and then return.
- ~RET %node の`~data$内で[ %offset 個目の`符号単位$の直後( %offset ~EQ 0 なら先頭)から, %count 個の`符号単位$ ]並びが成す文字列 ◎ Return a string whose value is the code units from the offsetth code unit to the offset+countth code unit in node’s data.
4.11. ^@Text ~interface
!! [`Exposed$=Window] interface @Text : $CharacterData { `Text$mc(optional $DOMString %data = ""); [`NewObject$] $Text $splitText(`unsigned long$ %offset); ~RA $DOMString $wholeText; }; !- %text = $Text([data = ""])
- `~data$が %data にされた,新たな $Text `~node$を返す。 ◎ Returns a new Text node whose data is data.
- %text . $splitText(offset)
- 所与の %offset の地点で`~data$を分割し,残りの部分を $Text `~node$として返す。 ◎ Splits data at the given offset and returns the remainder as Text node.
- %text . $wholeText
- 隣接するすべての`同胞$ $Text `~node$の`~data$を連結した結果を返す。 ◎ Returns the combined data of all direct Text node siblings.
`新たな~Text~node@( %文字列, %文書 ) という表記は、次のように設定された新たな $Text `~node$を意味する ⇒ ( `~data$, `~node文書$ ) ~SET ( %文字列, %文書 )
【 この表記は、簡潔に記述するため,この訳に導入したものである。 】
`狭義の~Text~node@ とは、 $CDATASection `~node$でない $Text `~node$である。 ◎ An exclusive Text node is a Text node that is not a CDATASection node.
`~node$ %~node を含む `連続的な~Text~node列@ とは、条件[ $Text `~node$である ]を満たす, %~node を含む`連続的な同胞~列$である。 ◎ The contiguous Text nodes of a node node are node, node’s previous sibling Text node, if any, and its contiguous Text nodes, and node’s next sibling Text node, if any, and its contiguous Text nodes, avoiding any duplicates.
`~node$ %~node を含む `連続的な狭義の~Text~node列@ とは、条件[ `狭義の~Text~node$である ]を満たす, %~node を含む`連続的な同胞~列$である。 ◎ The contiguous exclusive Text nodes of a node node are node, node’s previous sibling exclusive Text node, if any, and its contiguous exclusive Text nodes, and node’s next sibling exclusive Text node, if any, and its contiguous exclusive Text nodes, avoiding any duplicates.
【 この訳では、次の手続きを導入して,原文による “連続的な…” の(再帰的な)定義を、等価な(かつ平坦~化された平易な)定義に変形している。 】
条件 %条件 を満たす, %~node を含む `連続的な同胞~列@ は、次を走らせた結果で与えられる:
- ~Assert: %~node は %条件 を満たす
- ~WHILE[ %~node の`前-同胞?$は %条件 を満たす ] ⇒ %~node ~SET %~node の`前-同胞?$
- %~list ~LET 空~list
-
~WHILE[ %~node は %条件 を満たす ]:
- %~list に %~node を付加する
- %~node ~SET %~node の`次-同胞?$
- ~RET %~list
`~node$ %~node の `子~text内容@ は、次を`連結-$した結果を返す ⇒ `~tree順序$による[ %~node の`子$のうち $Text ~nodeであるもの ]すべての`~data$ ◎ The child text content of a node node is the concatenation of the data of all the Text node children of node, in tree order.
`~node$ %~node の `子孫~text内容@ は、次を`連結-$した結果を返す ⇒ `~tree順序$による[ %~node の`子孫$のうち $Text `~node$であるもの ]すべての`~data$ ◎ The descendant text content of a node node is the concatenation of the data of all the Text node descendants of node, in tree order.
@Text(data) 構築子~手続きは ⇒# コレの`~data$ ~SET %data, コレの`~node文書$ ~SET `現在の大域~obj$に`結付けられている文書$ ◎ The Text(data) constructor, when invoked, must return a new Text node whose data is data and node document is current global object’s associated Document.
`~Text~nodeを分割する@ ときは、所与の ( $Text `~node$ %node, ~offset %offset ) に対し,次を走らす: ◎ To split a Text node node with offset offset, run these steps:
- %count ~LET %長さ ~MINUS %offset ◎ Let count be length minus offset.
- %新-~data ~LET コレの`~dataの部分文字列$( %offset, %count ) ◎ Let new data be the result of substringing data with node node, offset offset, and count count.
- %新-~node ~LET `新たな~Text~node$( %新-~data, %node の`~node文書$ ) ◎ Let new node be a new Text node, with the same node document as node. Set new node’s data to new data.
- %親 ~LET %node の`親$ ◎ Let parent be node’s parent.
-
~IF[ %親 ~NEQ ~NULL ]: ◎ If parent is not null, then:
- %親 の中で`~nodeを子の前に挿入する$( %新-~node, %node の`次-同胞?$ ) ◎ Insert new node into parent before node’s next sibling.
-
~EACH( `~live範囲o$ %範囲o ) に対し: ◎ ↓
- ~IF[ %範囲o の`始端~node$ ~EQ %node ]~AND[ %範囲o の`始端~offset$ ~GT %offset ] ⇒# %範囲o の`始端~node$ ~SET %新-~node; %範囲o の`始端~offset$ ~DECBY %offset ◎ For each live range whose start node is node and start offset is greater than offset, set its start node to new node and decrease its start offset by offset.
- ~IF[ %範囲o の`終端~node$ ~EQ %node ]~AND[ %範囲o の`終端~offset$ ~GT %offset ] ⇒# %範囲o の`終端~node$ ~SET %新-~node; %範囲o の`終端~offset$ ~DECBY %offset ◎ For each live range whose end node is node and end offset is greater than offset, set its end node to new node and decrease its end offset by offset.
- ~IF[ %範囲o の`始端~node$ ~EQ %親 ]~AND[ %範囲o の`始端~offset$ ~EQ %node の`~index$ ~PLUS 1 ] ⇒ %範囲o の`始端~offset$ ~INCBY 1 ◎ For each live range whose start node is parent and start offset is equal to the index of node plus 1, increase its start offset by 1.
- ~IF[ %範囲o の`終端~node$ ~EQ %親 ]~AND[ %範囲o の`終端~offset$ ~EQ %node の`~index$ ~PLUS 1 ] ⇒ %範囲o の`終端~offset$ ~INCBY 1 ◎ For each live range whose end node is parent and end offset is equal to the index of node plus 1, increase its end offset by 1.
- %node の`~dataを置換する$( %offset, %count, 空~文字列 ) ◎ Replace data with node node, offset offset, count count, and data the empty string.
- ~RET %新-~node ◎ Return new node.
4.12. ^@CDATASection ~interface
!! [`Exposed$=Window] interface @CDATASection : $Text { }; !4.13. ^@ProcessingInstruction ~interface
!! [`Exposed$=Window] interface @ProcessingInstruction : $CharacterData { ~RA $DOMString $target; }; !各 $ProcessingInstruction `~node$には、次に挙げるものが結付けられる:
- `~target@pI
- 文字列。
4.14. ^@Comment ~interface
!! [`Exposed$=Window] interface @Comment : $CharacterData { `Comment$mc(optional $DOMString %data = ""); }; !- %comment = $Comment([data = ""])
- `~data$が %data にされた,新たな $Comment `~node$を返す。 ◎ Returns a new Comment node whose data is data.
@Comment(data) 構築子~手続きは ⇒# コレの`~data$ ~SET %data, コレの`~node文書$ ~SET `現在の大域~obj$に`結付けられている文書$ ◎ The Comment(data) constructor, when invoked, must return a new Comment node whose data is data and node document is current global object’s associated Document.
5. 範囲o
5.1. “DOM Ranges” 序論
[ $StaticRange / $Range ]~obj ( `範囲o$ )は`~node~tree$の中の連続する内容を表現する。 各 `範囲o$ は、`境界点$と呼ばれる[ ( `始端$, `終端$ ) が成す`~tuple$ ]を持つ。 各 `境界点$は、 ( `~node$bp, `~offset$bp ) が成す`~tuple$である。 言い換えれば、`範囲o$は`~node~tree$の中の 2 つの`境界点$に挟まれる `中身@rg を表現する。 ◎ StaticRange and Range objects (ranges) represent a sequence of content within a node tree. Each range has a start and an end which are boundary points. A boundary point is a tuple consisting of a node and an offset. So in other words, a range represents a piece of content within a node tree between two boundary points.
`範囲o$は、編集-時に内容を選択したり複製するときに よく利用される。 例えば 次の`~node~tree$が与えられたとき: ◎ Ranges are frequently used in editing for selecting and copying content.
- `要素$: `p^e
- `要素$: `img^e, ^src=`insanity-wolf^l ^alt=`Little-endian BOM; decode as big-endian!^l
- $Text: CSS 2.1 syndata is
- `要素$: `em^e
- $Text: awesome
- $Text: !
次の様にして, `syndata is awes^l の並びを表現する`範囲o$が得られる(変数[ %p / %em ]には[ `p^e / `em^e ]`要素$が割当されたとする): ◎ In the node tree above, a range can be used to represent the sequence “syndata is awes”. Assuming p is assigned to the p element, and em to the em element, this would be done as follows:
var %range = new Range(), %text1 = %p.childNodes[1], %text2 = %em.firstChild %range.setStart(%text1, 9) /* 先頭の空白も数に入れる ◎ do not forget the leading space */ %range.setEnd(%text2, 4) /* %range を文字列~化した結果は、今や先に示した文字列になる ◎ range now stringifies to the aforementioned quote */
注記: `範囲o$は、上の`~node~tree$の ^src や ^alt などの`属性o$は表現できない。 `範囲o$は`~node$用に限り有用になる。 ◎ Attributes such as src and alt in the node tree above cannot be represented by a range. Ranges are only useful for nodes.
$StaticRange ~objと違って、 $Range ~objは,`~node~tree$に対する変異に影響される。 なので、`~live範囲o$とも称される。 その種の変異によりそれらが無効~化されることはなく,可能なら内容の同じ部分を表現するようにされる。 `~live範囲o$は、`~node~tree$に対する変異 — 自身が表現する`中身$rgの一部が変異したときなど — に伴い,必要に応じて自身も改変され得る。 ◎ Range objects, unlike StaticRange objects, are affected by mutations to the node tree. Therefore they are also known as live ranges. Such mutations will not invalidate them and will try to ensure that it still represents the same piece of content. Necessarily, a live range might itself be modified as part of the mutation to the node tree when, e.g., part of the content it represents is mutated.
詳細は、次に挙げる各種~algo/~methodを見よ ⇒# `~nodeを子の前に挿入する$, `~nodeを除去する$ $Node.normalize(), `~dataを置換する$, `~Text~nodeを分割する$ ◎ See the insert and remove algorithms, the normalize() method, and the replace data and split algorithms for details.
【 例えば,範囲oの境界点が ある~nodeの “内部” を指していて, その~nodeが~treeから除去された場合、その境界点は “~nodeが抜けた穴” を指すようにされる(始端と終端が別々の~treeの中を指さないようにされる)。 始端と終端の両者が同じ~nodeの内部を指していたとしても、除去された~nodeの内部を指すことはなく,それらは同じ “穴” を指す様に畳まれることになる。 】
`~node~tree$の変異に呼応して,`~live範囲o$を更新することは、高価になり得る。 `~node~tree$が変化するたびに、影響されるすべての $Range ~objは更新される必要がある。 ~appが`~live範囲o$に関心がなくなろうが、変異が生じたときには,それらを最新に保つ~costを支払うことになる。 ◎ Updating live ranges in response to node tree mutations can be expensive. For every node tree change, all affected Range objects need to be updated. Even if the application is uninterested in some live ranges, it still has to pay the cost of keeping them up-to-date when a mutation occurs.
$StaticRange ~objは、`~node~tree$が変異しても更新されない,軽量な`範囲o$であり、したがって, `~live範囲o$と同じ保守~costの~subjectにならない。 ◎ A StaticRange object is a lightweight range that does not update when the node tree mutates. It is therefore not subject to the same maintenance cost as live ranges.
5.2. 境界点
`境界点@ とは、[ `~node@bp (`~node$), `~offset@bp (負でない整数) ]が成す`~tuple$である。 ◎ A boundary point is a tuple consisting of a node (a node) and an offset (a non-negative integer).
以下では,所与の[ `~node$ %node, `~offset$bp %offset ]で初期化された`境界点$を、 “境界点( %node, %offset )” の様に表記する。 【この表記は、この訳による追加。】
注記: 正しい`境界点$の`~offset$bpは、 0 以上, `境界点$の`~node$bpの`長さ$以下になる。 ◎ A correct boundary point’s offset will be between 0 and the boundary point’s node’s length, inclusive.
【 ~HTMLや~XMLの~source~textの中では,境界点は、すべての~text~data(`文字~data~node$)を “仮想の” 開始~tag, 終了~tag で括り, すべての空~要素(~HTMLの~void要素も含む)は 開始/終了 ~tagの組に置換した上で、すべての[ ~tag, および 文字~dataを成す`符号単位$たち ]それぞれを点に見立てて,~sourceに現れる順に一列に並べたときの,隣接する任意の 2 つの点の隙間を指すものと見なせる。
例えば "<b>text</b>" のような~markupの中の,[ 開始~tag "<b>" ]と[ "text" の先頭 ]との隙間を指す境界点には、 "text" ~node の[ 内縁(“仮想の”~tagの内縁)を指すもの, および 外縁を指すもの ]があり、また,境界点は[ "<br>" のような空~tag / ~dataが空な`文字~data~node$ ]の内部も指し得る†。
† 唯一の~~例外は,`~doctype$であり、境界点は~doctypeの内部は指し得ないようにされている — したがってこの~modelでは,一個の “点” になる。
文書の~node~treeの一例とそのすべての境界点を示す模式図を次に示す。 縦棒 "|" が境界点が指し得る位置を表し,ドット "." が文字~dataの各~文字を表す( 先掲の模式図 同様,左端が文書の先頭, 右端が文書の末尾,横線は~treeの中の各 ~nodeが文書~内を占める~~範囲を表し,~COLOR_Rは`文字~data~node$を表す):
`[|*|(|A)|[|[|B]|(|.|)|C(|.|.|)|[|(|.|)|]|[|]|(|.|.|)|[x|0(|.|)|1[|(|.|)|]|2[|(|.|.|.|)|[|(|.|)|]|]|3(|.|.|)|4]|]|(|.|.|)|]^bpex境界点を表す縦棒の直上の横線がその境界点の~nodeを表す。 境界点の~offsetは、図の中では,その境界点を表す縦棒の直上の横線直下にあって, その縦棒より左側に位置する縦棒の本数になる(境界点の~nodeが図の~COLOR_Xならば、その直下の`各数字^mkがその境界点の~offset)。
図の先頭の `*^c は`~doctype$を表す(内部に境界点は無い)。 その次の孤立した `A^mk は~dataが空な`文字~data~node$の内部を指す(唯一の)境界点を表し,その次の `B^mk は内容が空な要素の内部を指す境界点を表し,~~後続の 2 個の~COLOR_Rは 2 個の`文字~data~node$が境界点( `C^mk )を挟んで間を置かずに連続していることを表している。 】
`境界点$ %A の[ `境界点$ %B に `相対的な位置bp@ ]が, %B [ `より前@i / `に等しい@i / `より後@i ]のいずれかになるかは、次に従って決定される: ◎ The position of a boundary point (nodeA, offsetA) relative to a boundary point (nodeB, offsetB) is before, equal, or after, as returned by these steps:
【 この~algoは、 2 つの境界点に対し,上に示した様な模式図における位置関係(左側が “より前” )を算出する。 】
- ( %nodeA, %offsetA, %nodeB, %offsetB ) ~LET ( %A の`~node$bp, %A の`~offset$bp, %B の`~node$bp, %B の`~offset$bp ) ◎ ↑
- ~Assert: %nodeA の`根$ ~EQ %nodeB の`根$ ◎ Assert: nodeA and nodeB have the same root.
- ~IF[ %nodeA ~EQ %nodeB ] ⇒ ~RET [ %offsetA ~LT %offsetB ならば `より前$i / %offsetA ~EQ %offsetB ならば `に等しい$i / %offsetA ~GT %offsetB ならば `より後$i ] ◎ If nodeA is nodeB, then return equal if offsetA is offsetB, before if offsetA is less than offsetB, and after if offsetA is greater than offsetB.
- ~IF[ %nodeA は %nodeB に`後続-$する ] ⇒ ~RET %B は %A [ `より前$i ならば `より後$i / `より後$i ならば `より前$i ] ◎ If nodeA is following nodeB, then if the position of (nodeB, offsetB) relative to (nodeA, offsetA) is before, return after, and if it is after, return before.
-
~IF[ %nodeA は %nodeB の`先祖$である ]: ◎ If nodeA is an ancestor of nodeB:
- %子 ~LET %nodeB ◎ Let child be nodeB.
- ~WHILE[ %子 の`親$ ~NEQ %nodeA ] ⇒ %子 ~SET %子 の`親$ ◎ While child is not a child of nodeA, set child to its parent.
- ~IF[ %子 の`~index$ ~LT %offsetA ] ⇒ ~RET `より後$i ◎ If child’s index is less than offsetA, then return after.
- ~RET `より前$i ◎ Return before.
5.3. ^@AbstractRange ~interface
!! [`Exposed$=Window] interface @AbstractRange { ~RA $Node $startContainer; ~RA `unsigned long$ $startOffset; ~RA $Node $endContainer; ~RA `unsigned long$ $endOffset; ~RA $boolean $collapsed; }; !$AbstractRange ~interfaceを実装する~objは単に `範囲o@ とも称される。 ◎ Objects implementing the AbstractRange interface are known as ranges.
【 一般語の “~~範囲” と区別し易くするため、この訳では, “°” を付けて “範囲o” と記すことにする( “DOM range”, “~~範囲~obj” などの呼称もあるが)。 】
各 `範囲o$には、 2 つの`境界点$ `始端@, `終端@ が結付けられる。 ◎ A range has two associated boundary points — a start and end.
便宜のため、`範囲o$の: ◎ For convenience,\
- ( `始端~node@, `始端~offset@ ) は、順に,`始端$の ( `~node$bp, `~offset$bp ) を指すとする。 ◎ a range’s start node is its start’s node, its start offset is its start’s offset,\
- ( `終端~node@, `終端~offset@ ) は、順に,`終端$の ( `~node$bp, `~offset$bp ) を指すとする。 ◎ its end node is its end’s node, and its end offset is its end’s offset.
所与の`範囲o$は、次を満たすとき `畳まれて@ いるとされる 【!等bp】 ⇒ [ `始端~node$ ~EQ `終端~node$ ]~AND[ `始端~offset$ ~EQ `終端~offset$ ] ◎ A range is collapsed if its start node is its end node and its start offset is its end offset.
- %node = %range . $startContainer
- %range の`始端~node$を返す。 ◎ Returns range’s start node.
- %offset = %range . $startOffset
- %range の`始端~offset$を返す。 ◎ Returns range’s start offset.
- %node = %range . $endContainer
- %range の`終端~node$を返す。 ◎ Returns range’s end node.
- %offset = %range . $endOffset
- %range の`終端~offset$を返す。 ◎ Returns range’s end offset.
- %collapsed = %range . $collapsed
- %range は`畳まれて$いるならば ~T を, 他の場合は~F を返す。 ◎ Returns true if range is collapsed, and false otherwise.
5.4. ^StaticRange ~interface
!! dictionary @@StaticRangeInit { required $Node @startContainer; required `unsigned long$ @startOffset; required $Node @endContainer; required `unsigned long$ @endOffset; }; [`Exposed$=Window] interface @@StaticRange : $AbstractRange { `StaticRange$mc($StaticRangeInit %init); }; !- %staticRange = $StaticRange(init)
- `~node~tree$が変異しても更新しない,新たな`範囲o$を返す。 ◎ Returns a new range object that does not update when the node tree mutates.
@StaticRange(init) 構築子~手続きは:
- %始端~node ~LET %init[ "$startContainer" ]
- %終端~node ~LET %init[ "$endContainer" ]
- ~IF[ %始端~node, %終端~node いずれかは[ $DocumentType / $Attr ]`~node$である ] ⇒ ~THROW `InvalidNodeTypeError$E
- コレの`始端$ ~SET `境界点$( %始端~node, %init[ "$startOffset" ] ),
- コレの`終端$ ~SET `境界点$( %終端~node, %init[ "$endOffset" ] )
5.5. ^@Range ~interface
!! [`Exposed$=Window] interface @Range : $AbstractRange { `Range$mc(); ~RA $Node $commonAncestorContainer; $undefined $setStart($Node %node, `unsigned long$ %offset); $undefined $setEnd($Node %node, `unsigned long$ %offset); $undefined $setStartBefore($Node %node); $undefined $setStartAfter($Node %node); $undefined $setEndBefore($Node %node); $undefined $setEndAfter($Node %node); $undefined $collapse(optional $boolean %toStart = false); $undefined $selectNode($Node %node); $undefined $selectNodeContents($Node %node); const `unsigned short$ @START_TO_START = 0; const `unsigned short$ @START_TO_END = 1; const `unsigned short$ @END_TO_END = 2; const `unsigned short$ @END_TO_START = 3; $short $compareBoundaryPoints(`unsigned short$ %how, $Range %sourceRange); [`CEReactions$] $undefined $deleteContents(); [`CEReactions$, `NewObject$] $DocumentFragment $extractContents(); [`CEReactions$, `NewObject$] $DocumentFragment $cloneContents(); [`CEReactions$] $undefined $insertNode($Node %node); [`CEReactions$] $undefined $surroundContents($Node %newParent); [`NewObject$] $Range $cloneRange(); $undefined $detach(); $boolean $isPointInRange($Node %node, `unsigned long$ %offset); $short $comparePoint($Node %node, `unsigned long$ %offset); $boolean $intersectsNode($Node %node); $stringifier; }; !$Range ~interfaceを実装する~objは単に `~live範囲o@ とも称される。 ◎ Objects implementing the Range interface are known as live ranges.
注記: `~tree$を改変する~algo(特に, `~nodeを子の前に挿入する$, `~nodeを除去する$, `~dataを置換する$, `~Text~nodeを分割する$ )は、その`~tree$に結付けられている一連の`~live範囲o$も改変する。 ◎ Algorithms that modify a tree (in particular the insert, remove, replace data, and split algorithms) modify live ranges associated with that tree.
`~live範囲o$の `根@rg とは、その`始端~node$の`根$である。 ◎ The root of a live range is the root of its start node.
【 `終端~node$の`根$と同じになる(常にそうなるように拘束される)。 各 `~live範囲o$は、その作成-時からずっと,同じある`~node~tree$に結付けられ続ける — 言い換えれば、`根$rgは変化しない。 (仕様には明示的にそう述べられてはいないが、各種~algoの挙動から,そう結論できる。 一般の`範囲o$についても同じことが言えるかどうかは、はっきりしない。) 】
次をいずれも満たす`~node$ %node は、`~live範囲o$ %範囲o に `包含され@ ているとされる: ◎ A node node is contained in a live range range if\
- %node の`根$ ~EQ %範囲o の`根$rg ◎ node’s root is range’s root, and \
- `境界点$( %node, 0 ) は %範囲o の`始端$`より後$i ◎ (node, 0) is after range’s start, and\
- `境界点$( %node, %node の`長さ$ ) は %範囲o の`終端$`より前$i ◎ (node, node’s length) is before range’s end.
次のいずれかを満たす`~node$ %node は、`~live範囲o$ %範囲o に `部分的に包含され@ ているとされる: ◎ A node is partially contained in a live range if\
- [ %node は %範囲o の`始端~node$の`広義先祖$である ]~AND[ %node は %範囲o の`終端~node$の`広義先祖$でない ] ◎ it’s an inclusive ancestor of the live range’s start node but not its end node, or\
- [ %node は %範囲o の`始端~node$の`広義先祖$でない ]~AND[ %node は %範囲o の`終端~node$の`広義先祖$である ] ◎ vice versa.
【 次の図は先掲の模式図と同様に~treeを表したものであり,図の記号 `s^mk が始端, `e^mk が終端を表すとする。 このとき、図の~COLOR_Xの~nodeが包含され, ~COLOR_Yの~node(始端/終端の一方のみを内部に含む~node)が部分的に包含される。 最上層の横線の~nodeは 内部に `s^mk, `e^mk とも含むので、~~定義により,`部分的に包含され$ることはない。 】
`[|(|.|)|[|]|[y|(y|.|.|s)|]|[x|(x|.|)|]|(x|.|.|.|)|[x|]|(x|.|.|)|[y|(x|.|)|[x|(x|.|)|]|[y|(y|.|.|e.|)|[|(|.|)|]|]|(|.|.|)|]|]^bpex注記: これらの定義をより理解し易くする事実をいくつか挙げる: ◎ Some facts to better understand these definitions:
- `~live範囲o$の`中身$rgは、`包含され$ているすべての`~node$に加えて,[[ `始端~node$ / `終端~node$ ]の`広義子孫$である`文字~data~node$のうち,範囲oに入るもの ]からなるものとみなせる。 ◎ The content that one would think of as being within the live range consists of all contained nodes, plus possibly some of the contents of the start node and end node if those are Text, ProcessingInstruction, or Comment nodes.
- `~live範囲o$に`包含され$ている`~node$たちの集合は、`包含され$ている`~node$の`親$が常に`包含され$るとは限らないので,一般に連続的でない。 ◎ The nodes that are contained in a live range will generally not be contiguous, because the parent of a contained node will not always be contained.
- しかしながら,`包含され$ている`~node$の`子孫$は`包含され$ており、 2 つの`同胞$が`包含され$ているならば,それらの間に位置するどの`同胞$も`包含され$る。 ◎ However, the descendants of a contained node are contained, and if two siblings are contained, so are any siblings that lie between them.
- `~live範囲o$の`始端~node$ と`終端~node$ は決して その範囲oに`包含され$ない。 ◎ The start node and end node of a live range are never contained within it.
- `包含され$ている`~node$のうち、最初のもの(もし在れば)は,常に`始端~node$に`後続-$し、最後のものは,常に`終端~node$の最後の`子孫$と同じか, それに`先行-$する。 【!descendant を持たない場合は?】 ◎ The first contained node (if there are any) will always be after the start node, and the last contained node will always be equal to or before the end node’s last descendant.
- 部分的に包含される`~node$が存在するのは、`始端~node$ と`終端~node$ が異なるとき, そのときに限る。 ◎ There exists a partially contained node if and only if the start node and end node are different.
- `始端~node$と`終端~node$の`共通な広義先祖$は、`包含され$ることも, `部分的に包含され$ることもない。 ◎ The commonAncestorContainer attribute value is neither contained nor partially contained.
-
`始端~node$ %A が `終端~node$ %B の`先祖$である場合:
- %A が, %A, %B に`共通な広義先祖$になる。
- %A の`子$のうち, 1 つだけ( %C とする)が`部分的に包含され$る。
- %A の別の`子$ %C1 が`包含され$るのは、 %C1 が %C に`先行-$するとき, そのときに限る。
【 この場合の例。 前と同様,記号 `s^mk は始端, `e^mk は終端を表す。 この例では図の最上層の~nodeが共通な広義先祖になる。 共通な広義先祖の子のうち、~COLOR_Yの~nodeが上述の %C (共通な広義先祖の子であってかつ部分的に包含される)に該当し,~COLOR_Xの~nodeが`包含され$る子になる。 】
`[|(|.|)|s[x|(|.|)|]|(x|.|.|)|[x|(|.|.|)|]|[y|[|(|.|)|]|(|.|.|e.|)|[|(|.|)|]|]|(|.|.|)|]^bpex%B が %A の`先祖$である場合、前述の逆になる。 【上の図で、 `s^mk と `e^mk を入れ替えて,右端から~treeの順序が開始されていると考えるとよい。】
◎ If the start node is an ancestor of the end node, the common inclusive ancestor will be the start node. Exactly one of its children will be partially contained, and a child will be contained if and only if it precedes the partially contained child. If the end node is an ancestor of the start node, the opposite holds. - `始端~node$ %A, `終端~node$ %B とも他方の`広義先祖$でない場合: %A, %B の`共通な広義先祖$ %先祖 は、 %A とも %B とも異なる。 %先祖 の`子$のうち,ちょうど 2 個が`部分的に包含され$、 %先祖 の`子$が`包含され$るのは,これら 2 個の合間に在るとき, そのときに限る。 ◎ If the start node is not an inclusive ancestor of the end node, nor vice versa, the common inclusive ancestor will be distinct from both of them. Exactly two of its children will be partially contained, and a child will be contained if and only if it lies between those two.
- %range = $Range()
- 新たな`~live範囲o$を返す。 ◎ Returns a new live range.
@Range() 構築子~手続きは:
- %文書 ~LET `現在の大域~obj$に`結付けられている文書$
- コレの`始端$ ~SET `境界点$( %文書, 0 )
- コレの`終端$ ~SET `境界点$( %文書, 0 )
- %container = %range . $commonAncestorContainer
- %range の[ `始端~node$, `終端~node$ ]両者の`広義先祖$であるような,最も末端の~nodeを返す。 【原文の “ancestor” (先祖)は~~厳密な記述ではない。】 ◎ Returns the node, furthest away from the document, that is an ancestor of both range’s start node and end node.
【この訳では便宜のため,次を定義する:】 同じ~treeに`関与して$いる 2 つの~node %A, %B の(最も末端の) `共通な広義先祖@ は、次の~algoを走らせた結果を返す:
- ~WHILE[ %A は %B の`広義先祖$でない ] ⇒ %A ~SET %A の`親$
- ~RET %A
【 次のブロックは、原文には存在しない,この訳による補完。 ブロックにて挙げる各種~methodは、範囲oの片方または両方の境界点を新たな地点に変更する。 片方の境界点(以下, %P )のみを変更する~methodについては、整合性を保つため,もう片方の境界点(以下, %Q )も必要に応じて~~正される: すなわち, %Q が[ %P と異なる~treeの中に在る, または[ %P `より前$i(始端が変更された場合) / %P `より後$i(終端が変更された場合) ]に位置する ]ようになった場合、 %P と同じ地点にされる( 範囲oは畳まれる)。 】
- %range . $setStart(node, offset)
- %range . $setEnd(node, offset)
- それぞれ,始端/終端を `境界点$( %node, %offset ) と同じ位置にする。
- %node が`~doctype$である場合, `InvalidNodeTypeError$E 例外が投出される。 他の場合, %offset が %node の`長さ$を超えている場合, `IndexSizeError$E 例外が投出される。
- %range . $setStartBefore(node)
- %range . $setStartAfter(node)
- それぞれ,始端を %node の外縁の[ 始端(下図の `S^mk )/終端(下図の `E^mk ) ]に位置させる。
- %node の`親$が~NULL の場合, `InvalidNodeTypeError$E 例外が投出される。
- %range . $setEndBefore(node)
- %range . $setEndAfter(node)
- それぞれ,終端を %node の外縁の[ 始端(下図の `S^mk )/終端(下図の `E^mk ) ]に位置させる。
- %node の`親$が~NULL の場合, `InvalidNodeTypeError$E 例外が投出される。
- (説明用の図式 — %node 引数が,図の~COLOR_Yが表す~nodeに対応しているとする。) `[|(|.|)|[|(|.|)|S[y|s[|(|.|)|]|(|.|.|.|)|[|]|e]|E(|.|.|)|]|]^bpex
- %range . $collapse(toStart)
- 範囲oを畳む — すなわち、 %toStart が ~T の場合は 終端を始端と同じ地点に位置させ,他の場合は 始端を終端と同じ地点に位置させる。
- %range . $selectNode(node)
- %node を選択する — すなわち、始端と終端を %node の外縁の両端(上図の `S^mk, `E^mk )に位置させる。
- %node の`親$が~NULL の場合, `InvalidNodeTypeError$E 例外が投出される。
- %range . $selectNodeContents(node)
- %node の内容を選択する — すなわち、始端と終端を %node の内縁の両端(上図の `s^mk, `e^mk )に位置させる。
- %node が`~doctype$である場合, `InvalidNodeTypeError$E 例外が投出される。
- %range . $compareBoundaryPoints(how, sourceRange)
- %range の始端または終端( %how により指示される)の位置bpが, %sourceRange の始端または終端( %how により指示される)[ `より前$i, `に等しい$i, `より後$i ]のいずれになるかに応じて、[ −1, 0, 1 ]を返す。
`範囲o$ %範囲o の `境界点を設定する@ ときは、所与の ( %端 ~IN { `始端^i, `終端^i }, `~node$ %node, 負でない整数 %offset ) に対し,次を走らす: ◎ To set the start or end of a range to a boundary point (node, offset), run these steps:
- ~IF[ %node は`~doctype$である ] ⇒ ~THROW `InvalidNodeTypeError$E ◎ If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
- ~IF[ %offset ~GT %node の`長さ$ ] ⇒ ~THROW `IndexSizeError$E ◎ If offset is greater than node’s length, then throw an "IndexSizeError" DOMException.
- %境界点 ~LET `境界点$( %node, %offset ) ◎ Let bp be the boundary point (node, offset).
-
~IF[ %端 ~EQ `始端^i ]: ◎ If these steps were invoked as "set the start"
- ~IF[ %範囲o の`根$rg ~NEQ %node の`根$ ]~OR[ %境界点 は %範囲o の`終端$`より後$i ] ⇒ %範囲o の`終端$ ~SET %境界点 ◎ If range’s root is not equal to node’s root, or if bp is after the range’s end, set range’s end to bp.
- %範囲o の`始端$ ~SET %境界点 ◎ Set range’s start to bp.
-
~ELSE( %端 ~EQ `終端^i ) ◎ If these steps were invoked as "set the end"
- ~IF[ %範囲o の`根$rg ~NEQ %node の`根$ ]~OR[ %境界点 は %範囲o の`始端$`より前$i ] ⇒ %範囲o の`始端$ ~SET %境界点 ◎ If range’s root is not equal to node’s root, or if bp is before the range’s start, set range’s start to bp.
- %範囲o の`終端$ ~SET %境界点 ◎ Set range’s end to bp.
@setStartBefore(node) ~method~手続きは: ◎ The setStartBefore(node) method, when invoked, must run these steps:
- %親 ~LET %node の`親$ ◎ Let parent be node’s parent.
- ~IF[ %親 ~EQ ~NULL ] ⇒ ~THROW `InvalidNodeTypeError$E ◎ If parent is null, then throw an "InvalidNodeTypeError" DOMException.
- コレの`境界点を設定する$( `始端^i, %親, %node の`~index$ ) ◎ Set the start of this to boundary point (parent, node’s index).
@setStartAfter(node) ~method~手続きは: ◎ The setStartAfter(node) method, when invoked, must run these steps:
- コレの`境界点を設定する$( `始端^i, %親, %node の`~index$ ~PLUS 1 ) ◎ Set the start of this to boundary point (parent, node’s index plus 1).
@setEndBefore(node) ~method~手続きは: ◎ The setEndBefore(node), when invoked, method must run these steps:
- コレの`境界点を設定する$( `終端^i, %親, %node の`~index$ ) ◎ Set the end of this to boundary point (parent, node’s index).
@setEndAfter(node) ~method~手続きは: ◎ The setEndAfter(node) method, when invoked, must run these steps:
- コレの`境界点を設定する$( `終端^i, %親, %node の`~index$ ~PLUS 1 ) ◎ Set the end of this to boundary point (parent, node’s index plus 1).
@collapse(toStart) ~method~手続きは: ◎ The collapse(toStart) method, when invoked, must\
- ~IF[ %toStart ~EQ ~T ] ⇒ コレの`終端$ ~SET `境界点$( コレの`始端~node$, コレの`始端~offset$ ) ◎ if toStart is true, set end to start, and\
- ~ELSE ⇒ コレの`始端$ ~SET `境界点$( コレの`終端~node$, コレの`終端~offset$ ) ◎ set start to end otherwise.
`~node$ %node を,`範囲o$ %範囲o の `中身として選択-@rg するときは、次を走らす: ◎ To select a node node within a range range, run these steps:
- %index ~LET %node の`~index$ ◎ Let index be node’s index.
- %範囲o の`始端$ ~SET `境界点$( %親, %index ) ◎ Set range’s start to boundary point (parent, index).
- %範囲o の`終端$ ~SET `境界点$( %親, %index ~PLUS 1 ) ◎ Set range’s end to boundary point (parent, index plus 1).
@selectNode(node) ~method~手続きは ⇒ %node を,コレの`中身として選択-$rgする ◎ The selectNode(node) method, when invoked, must select node within this.
@selectNodeContents(node) ~method~手続きは: ◎ The selectNodeContents(node) method, when invoked, must run these steps:
- ~IF[ %node は`~doctype$である ] ⇒ ~THROW `InvalidNodeTypeError$E ◎ If node is a doctype, throw an "InvalidNodeTypeError" DOMException.
- %長さ ~LET %node の`長さ$ ◎ Let length be the length of node.
- コレの`始端$ ~SET `境界点$( %node, 0 ) ◎ Set start to the boundary point (node, 0).
- コレの`終端$ ~SET `境界点$( %node, %長さ ) ◎ Set end to the boundary point (node, length).
@compareBoundaryPoints(how, sourceRange) ~method~手続きは: ◎ The compareBoundaryPoints(how, sourceRange) method, when invoked, must run these steps:
- ~IF[ %how ~NIN { $START_TO_START, $START_TO_END, $END_TO_END, $END_TO_START } ] ⇒ ~THROW `NotSupportedError$E ◎ If how is not one of • START_TO_START • START_TO_END • END_TO_END • END_TO_START ◎ then throw a "NotSupportedError" DOMException.
- ~IF[ コレの`根$rg ~NEQ %sourceRange の`根$rg ] ⇒ ~THROW `WrongDocumentError$E ◎ If this’s root is not the same as sourceRange’s root, then throw a "WrongDocumentError" DOMException.
-
( %基準点, %この点 ) ~LET %how に応じて,次で与えられる 2 個の`境界点$: ◎ If how is:
- $START_TO_START:
- ( %sourceRange の`始端$, コレの`始端$ ) ◎ Let this point be this’s start. Let other point be sourceRange’s start.
- $START_TO_END:
- ( %sourceRange の`始端$, コレの`終端$ ) ◎ Let this point be this’s end. Let other point be sourceRange’s start.
- $END_TO_END:
- ( %sourceRange の`終端$, コレの`終端$ ) ◎ Let this point be this’s end. Let other point be sourceRange’s end.
- $END_TO_START:
- ( %sourceRange の`終端$, コレの`始端$ ) ◎ Let this point be this’s start. Let other point be sourceRange’s end.
- ~RET [ %この点 は %基準点 [ `より前$i ならば ~MINUS 1 / `に等しい$i ならば 0 / `より後$i ならば 1 ] ◎ If the position of this point relative to other point is ◎ before • Return −1. ◎ equal • Return 0. ◎ after • Return 1.
【 次のブロックは、原文には存在しない,この訳による補完。 ブロックにて挙げる各種~methodは、主に,範囲oの`中身$rgを操作する。 】
- %range . $deleteContents()
- `~live範囲o$の`中身$rgを削除した上で、範囲oの`境界点$を畳む。
-
`deleteContents()^c の実行例。 図の記号[ `s^mk, `e^mk ]が順に範囲の[ 始端, 終端 ]を表すとするとき、図左の~~状態から図右の~~状態になる。 包含されている~node(図の ~COLOR_X ), および 始端/終端~nodeの文字~dataのうち 範囲oに入る部分の文字(図の `+^c )が除去される。 部分的に包含されている~node(図の ~COLOR_Y )は除去されない。 この例では、始端 `s^mk が指す`文字~data~node$は,~dataは空になるが~node自体は残される。 図右の `S^mk, `E^mk が元の始端, 終端に対応する位置であるが、実行後の始端と終端は,図右の `X^mk (共通な広義先祖の直下)を指すようにされることに注意(範囲oは畳まれる)。 始端~nodeが終端~nodeの`広義先祖$であった場合、始端の位置は変化しない。 始端~nodeが終端~node の`広義子孫$であった場合、全体の終端(右端)から相対的な終端の位置は変化しない。
`[|[|]|[y|(y|s+|)|]|[x|(|.|)|]|[y|(x|.|)|[y|(y|+|+|e.|)|[|]|]|(|.|)|]|] → [|[|]|[y|(y|S)|]|X[y|[y|(y|E.|)|[|]|]|(|.|)|]|]^bpex - %range . $extractContents()
- `~live範囲o$の`中身$rgを~cloneした結果を返すと同時に,中身は削除する( “カット” )。 機能上は $cloneContents() と $deleteContents() の組み合わせと等価になる。
- %range . $cloneContents()
- `~live範囲o$の`中身を~clone$rgした結果を返す。 返される`中身$rgは、新たな`文書片$で包装される。
-
^cloneContents() の実行例。 図左の記号[ `s^mk, `e^mk ]が順に範囲の[ 始端, 終端 ]を表すとするとき、その間に挟まれた部分の~cloneが図右に示すように得られる( `S^mk, `E^mk が元の始端と終端に対応する位置)。 図の~COLOR_Yの 2 個の~nodeが,範囲に`部分的に包含され$ている子。 入れ物にあたる それらの`共通な広義先祖$は、~cloneにおいては`文書片$(~COLOR_X)に置換される。 始端 `s^mk が属する`文字~data~node$は~dataが空になるが、~node自体は[ その親から共通な広義先祖の子まで ]の先祖も含めて~cloneされる。
`[|[|]|[y|(|.|s)|(|.|)|]|(|.|)|[y|(|.|)|[|(|.|.|e.|)|[|]|]|(|.|)|]|] → [x|[y|(|S)|(|.|)|]|(|.|)|[y|(|.|)|[|(|.|.|E)|]|]|]^bpex - %range . $insertNode(node)
- `~live範囲o$の`中身$rgの先頭に %node を挿入する(`中身に挿入-$rgする)。
- %range . $surroundContents(newParent)
- `~live範囲o$の`中身$rgを %newParent ~nodeで包装する。 それに伴い、範囲oの始端, 終端は, %newParent の(外縁の)両端を指すようにされる。 包装するに先立って、 %newParent の元々の子はすべて除去され, %newParent 自身も元々の親から除去される。
-
^surroundContents(%newParent) の実行例。 記号 `s^mk は始端, `e^mk は終端を表すとき、それらに挟まれた区間が %newParent で包装される(図の~COLOR_Y)。 `部分的に包含され$るものは `Text^c 以外は許容されないので、始端と終端は `Text^c の層を~~無視すれば同じ親の直下に位置する必要がある(さもなければ例外が投出される)。 図の `e^mk の様に境界点が `Text^c ~node内に位置していた場合、その~nodeはそこで分割される。
`[|(|.|)|s[x|(|.|)|]|[x|(|.|.|)|[|]|]|(|.|e.|)|] → [|(|.|)|s[y|[x|(|.|)|]|[x|(|.|.|)|[|]|]|(|.|)|]|e(|.|)|]^bpex
@deleteContents() ~method~手続きは: ◎ The deleteContents() method, when invoked, must run these steps:
- ~IF[ コレは`畳まれて$いる ] ⇒ ~RET ◎ If this is collapsed, then return.
- ( %元の始端~node, %元の始端~offset, %元の終端~node, %元の終端~offset ) ~LET 順に,コレの ( `始端~node$, `始端~offset$, `終端~node$, `終端~offset$ ) ◎ Let original start node, original start offset, original end node, and original end offset be this’s start node, start offset, end node, and end offset, respectively.
-
~IF[ %元の始端~node ~EQ %元の終端~node ]~AND[ %元の始端~node は`文字~data~node$である ]: ◎ If original start node and original end node are the same, and they are a Text, ProcessingInstruction, or Comment node,\
- %元の始端~node の`~dataを置換する$( %元の始端~offset, %元の終端~offset ~MINUS %元の始端~offset, 空~文字列 ) ◎ replace data with node original start node, offset original start offset, count original end offset minus original start offset, and data the empty string,\
- ~RET ◎ and then return.
- %除去対象 ~LET [ コレに`包含され$ている`~node$のうち,`親$もコレに`包含され$ているものは除いたもの ]からなる,`~tree順序$の~list ◎ Let nodes to remove be a list of all the nodes that are contained in this, in tree order, omitting any node whose parent is also contained in this.
- ~IF[ %元の始端~node は %元の終端~node の`広義先祖$である ] ⇒# %新-~node ~LET %元の始端~node; %新-~offset ~LET %元の始端~offset ◎ If original start node is an inclusive ancestor of original end node, set new node to original start node and new offset to original start offset.
-
~ELSE:
- %新-~node ~LET ( %元の始端~node, %元の終端~node ) の`共通な広義先祖$
- %新-~offset ~LET [ %新-~node の`子$のうち, %元の始端~node の`広義先祖$である`~node$ † ]の`~index$ ~PLUS 1
【 見通しを良くするため、ここの訳は,原文を等価な記述に変形している。 前~段の条件の否定が成立することから † に該当する~nodeは必ず存在し, %新-~node に`部分的に包含され$ている子のうち 最初のものになる。 】
◎ Otherwise: • Let reference node equal original start node. • While reference node’s parent is not null and is not an inclusive ancestor of original end node, set reference node to its parent. • Set new node to the parent of reference node, and new offset to one plus the index of reference node. • If reference node’s parent were null, it would be the root of this, so would be an inclusive ancestor of original end node, and we could not reach this point. - ~IF[ %元の始端~node は`文字~data~node$である ] ⇒ %元の始端~node の`~dataを置換する$( %元の始端~offset, %元の始端~node の`長さ$ ~MINUS %元の始端~offset, 空~文字列 ) ◎ If original start node is a Text, ProcessingInstruction, or Comment node, replace data with node original start node, offset original start offset, count original start node’s length minus original start offset, data the empty string.
- %除去対象 内の ~EACH( %node ) に対し,`~tree順序$で ⇒ `~nodeを除去する$( %node ) ◎ For each node in nodes to remove, in tree order, remove node.
- ~IF[ %元の終端~node は`文字~data~node$である ] ⇒ %元の終端~node の`~dataを置換する$( 0, %元の終端~offset, 空~文字列 ) ◎ If original end node is a Text, ProcessingInstruction, or Comment node, replace data with node original end node, offset 0, count original end offset and data the empty string.
- コレの ⇒# `始端$ ~SET `境界点$( %新-~node, %新-~offset ); `終端$ ~SET `境界点$( %新-~node, %新-~offset ) ◎ Set start and end to (new node, new offset).
`~live範囲o$ %範囲o の `中身を抽出-@rg するときは、次を走らす: ◎ To extract a live range range, run these steps:
- %断片 ~LET 次のように設定された新たな`文書片$`~node$ ⇒ `~node文書$ ~SET %範囲o の`始端~node$の`~node文書$ ◎ Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document.
- ~IF[ %範囲o は`畳まれて$いる ] ⇒ ~RET %断片 ◎ If range is collapsed, then return fragment.
- ( %元の始端~node, %元の始端~offset, %元の終端~node, %元の終端~offset ) ~LET 順に, %範囲o の ( `始端~node$, `始端~offset$, `終端~node$, `終端~offset$ ) ◎ Let original start node, original start offset, original end node, and original end offset be range’s start node, start offset, end node, and end offset, respectively.
-
~IF[ %元の始端~node ~EQ %元の終端~node ]~AND[ %元の始端~node は`文字~data~node$である ]: ◎ If original start node is original end node, and they are a Text, ProcessingInstruction, or Comment node:
- %clone ~LET `~nodeを~cloneする$( %元の始端~node ) ◎ Let clone be a clone of original start node.
- %clone の`~data$ ~SET %元の始端~node の`~dataの部分文字列$( %元の始端~offset, ( %元の終端~offset ~MINUS %元の始端~offset ) ) ◎ Set the data of clone to the result of substringing data with node original start node, offset original start offset, and count original end offset minus original start offset.
- %断片 に`~nodeを付加する$( %clone ) ◎ Append clone to fragment.
- %元の始端~node の`~dataを置換する$( %元の始端~offset, %元の終端~offset ~MINUS %元の始端~offset, 空~文字列 ) ◎ Replace data with node original start node, offset original start offset, count original end offset minus original start offset, and data the empty string.
- ~RET %断片 ◎ Return fragment.
- %共通な広義先祖 ~LET ( %元の始端~node, %元の終端~node ) の`共通な広義先祖$ ◎ Let common ancestor be original start node. ◎ While common ancestor is not an inclusive ancestor of original end node, set common ancestor to its own parent.
- %部分的に包含されている最初の子 ~LET ~NULL ◎ Let first partially contained child be null.
- ~IF[ %元の始端~node は %元の終端~node の`広義先祖$でない ] ⇒ %部分的に包含されている最初の子 ~SET %範囲o に`部分的に包含され$ている[ %共通な広義先祖 の`子$ ]のうち,最初のもの ◎ If original start node is not an inclusive ancestor of original end node, set first partially contained child to the first child of common ancestor that is partially contained in range.
- %部分的に包含されている最後の子 ~LET ~NULL ◎ Let last partially contained child be null.
-
~IF[ %元の終端~node は %元の始端~node の`広義先祖$でない ] ⇒ %部分的に包含されている最後の子 ~SET %範囲o に`部分的に包含され$ている[ %共通な広義先祖 の`子$ ]のうち,最後のもの ◎ If original end node is not an inclusive ancestor of original start node, set last partially contained child to the last child of common ancestor that is partially contained in range.
注記: これらの変数~代入は実際に常にイミを成す。 例えば, %元の始端~node が %元の終端~node の`広義先祖$でない場合、[ %元の始端~node ~EQ %共通な広義先祖 ]にはなり得ないので[ %元の始端~node の広義先祖であって %共通な広義先祖 の子孫でもあるもの ]が 1 つ以上あり,それらは %範囲o に`部分的に包含され$、それらのうち %共通な広義先祖 の子であるものが該当するものになる。 逆の場合も同様になる。 また、 2 つの子がいずれも定義されたなら,それらは決して等しくならないことにも注意。 ◎ These variable assignments do actually always make sense. For instance, if original start node is not an inclusive ancestor of original end node, original start node is itself partially contained in range, and so are all its ancestors up until a child of common ancestor. common ancestor cannot be original start node, because it has to be an inclusive ancestor of original end node. The other case is similar. Also, notice that the two children will never be equal if both are defined.
- %包含されている子たち ~LET [ %共通な広義先祖 の`子$のうち, %範囲o に`包含され$ているもの ]すべてからなる,`~tree順序$による~list ◎ Let contained children be a list of all children of common ancestor that are contained in range, in tree order.
-
~IF[ %包含されている子たち 内に`~doctype$が在る ] ⇒ ~THROW `HierarchyRequestError$E ◎ If any member of contained children is a doctype, then throw a "HierarchyRequestError" DOMException.
注記: `~doctype$が`部分的に包含され$ることは決してないので、部分的に包含される~nodeを気にする必要はない。 それは 範囲o の境界点 【始端~node/終端~node】 にはなり得ず, 何かの先祖にもなり得ない。 ◎ We do not have to worry about the first or last partially contained node, because a doctype can never be partially contained. It cannot be a boundary point of a range, and it cannot be the ancestor of anything.
-
~ELSE ⇒# %新-~node ~LET %共通な広義先祖; %新-~offset ~LET %部分的に包含されている最初の子 の`~index$ ~PLUS 1
【 ここの訳は、原文の記述と同じ結果を得るものに簡略化している。 】
◎ Otherwise: • Let reference node equal original start node. • While reference node’s parent is not null and is not an inclusive ancestor of original end node, set reference node to its parent. • Set new node to the parent of reference node, and new offset to one plus reference node’s index. • If reference node’s parent is null, it would be the root of range, so would be an inclusive ancestor of original end node, and we could not reach this point. -
~IF[ %部分的に包含されている最初の子 は`文字~data~node$である ]: ◎ If first partially contained child is a Text, ProcessingInstruction, or Comment node:
この事例では, %部分的に包含されている最初の子 は %元の始端~node である。 ◎ In this case, first partially contained child is original start node.
- %clone の`~data$ ~SET %元の始端~node の`~dataの部分文字列$( %元の始端~offset, ( %元の始端~node の`長さ$ ~MINUS %元の始端~offset ) ) ◎ Set the data of clone to the result of substringing data with node original start node, offset original start offset, and count original start node’s length minus original start offset.
- %元の始端~node の`~dataを置換する$( %元の始端~offset, %元の始端~node の`長さ$ ~MINUS %元の始端~offset, 空~文字列 ) ◎ Replace data with node original start node, offset original start offset, count original start node’s length minus original start offset, and data the empty string.
-
~ELIF[ %部分的に包含されている最初の子 ~NEQ ~NULL ]: ◎ Otherwise, if first partially contained child is not null:
- %clone ~LET `~nodeを~cloneする$( %部分的に包含されている最初の子 ) ◎ Let clone be a clone of first partially contained child.
- %下位-範囲o ~LET 次のように設定された新たな`~live範囲o$ ⇒# `始端$ ~SET `境界点$( %元の始端~node, %元の始端~offset ), `終端$ ~SET `境界点$( %部分的に包含されている最初の子, %部分的に包含されている最初の子 の`長さ$ ) ◎ Let subrange be a new live range whose start is (original start node, original start offset) and whose end is (first partially contained child, first partially contained child’s length).
- %下位-断片 ~LET %下位-範囲o の`中身を抽出-$rgした結果 ◎ Let subfragment be the result of extracting subrange.
- %clone に`~nodeを付加する$( %下位-断片 ) ◎ Append subfragment to clone.
- %包含されている子たち 内の ~EACH( %包含されている子 ) に対し ⇒ %断片 に`~nodeを付加する$( %包含されている子 ) ◎ For each contained child in contained children, append contained child to fragment.
-
~IF[ %部分的に包含されている最後の子 は`文字~data~node$である ]: ◎ If last partially contained child is a Text, ProcessingInstruction, or Comment node:
注記: この事例では, %部分的に包含されている最後の子 は %元の始端~node である。 ◎ In this case, last partially contained child is original end node.
- %clone ~LET `~nodeを~cloneする$( %元の終端~node ) ◎ Let clone be a clone of original end node.
- %clone の`~data$ ~SET %元の終端~node の`~dataの部分文字列$( 0, %元の終端~offset ) ◎ Set the data of clone to the result of substringing data with node original end node, offset 0, and count original end offset.
- %元の終端~node の`~dataを置換する$( 0, %元の終端~offset, 空~文字列 ) ◎ Replace data with node original end node, offset 0, count original end offset, and data the empty string.
-
~ELIF[ %部分的に包含されている最後の子 ~NEQ ~NULL ]: ◎ Otherwise, if last partially contained child is not null:
- %clone ~LET `~nodeを~cloneする$( %部分的に包含されている最後の子 ) ◎ Let clone be a clone of last partially contained child.
- %下位-範囲o ~LET 次のように設定された新たな`~live範囲o$ ⇒# `始端$ ~SET `境界点$( %部分的に包含されている最後の子, 0 ), `終端$ ~SET `境界点$( %元の終端~node, %元の終端~offset ) ◎ Let subrange be a new live range whose start is (last partially contained child, 0) and whose end is (original end node, original end offset).
- %範囲o の ⇒# `始端$ ~SET `境界点$( %新-~node, %新-~offset ); `終端$ ~SET `境界点$( %新-~node, %新-~offset ) ◎ Set range’s start and end to (new node, new offset).
`~live範囲o$ %範囲o の`中身を~clone@rg するときは、次を走らす: ◎ To clone the contents of a live range range, run these steps:
-
-
-
- %下位-断片 ~LET %下位-範囲o の`中身を~clone$rgした結果 ◎ Let subfragment be the result of cloning the contents of subrange.
-
%包含されている子たち 内の ~EACH( %包含されている子 ) に対し: ◎ For each contained child in contained children:
- %clone ~LET `~nodeを~cloneする$( %包含されている子, ε, `子も~cloneする^i ) ◎ Let clone be a clone of contained child with the clone children flag set.
-
-
`~node$ %node を`~live範囲o$ %範囲o の `中身に挿入-@rg するときは,次を走らす: ◎ To insert a node node into a live range range, run these steps:
【 `始端$の直後に %node を挿入する。 それに伴い、終端は,末尾側からの相対位置が変化しないように適宜ずらされる(すなわち、挿入-後の 始端/終端 の,先頭/末尾 からの相対位置は不変)。 始端が`文字~data~node$の内部を指している場合、その~nodeは始端の所で 2 つに分割される。 】
- ( %始端~node, %始端~offset ) ~LET %範囲o の ( `始端~node$, `始端~offset$ ) ◎ ↓
-
~IF[ %始端~node は次のいずれかを満たす ] ⇒ ~THROW `HierarchyRequestError$E :
- $ProcessingInstruction ~nodeである
- $Comment ~nodeである
- [ $Text `~node$である ]~AND[ `親$ ~EQ ~NULL ]
- %始端~node ~EQ %node
- %基準~node ~LET ~NULL ◎ Let referenceNode be null.
- ~IF[ %始端~node は $Text `~node$である ] ⇒ %基準~node ~SET %始端~node ◎ If range’s start node is a Text node, set referenceNode to that Text node.
- ~ELIF[ %始端~node の`子$に[ `~index$ ~EQ %始端~offset ]なるものが在る ] ⇒ %基準~node ~SET それ ◎ Otherwise, set referenceNode to the child of start node whose index is start offset, and null if there is no such child.
- %親 ~LET [ %基準~node ~NEQ ~NULL ならば その`親$ / ~ELSE_ %始端~node ] ◎ Let parent be range’s start node if referenceNode is null, and referenceNode’s parent otherwise.
- %node を %親 の中で %基準~node の前に`挿入できるかどうか検証する$ ◎ Ensure pre-insertion validity of node into parent before referenceNode.
-
~IF[ %始端~node は $Text `~node$である ] ⇒ %基準~node ~SET `~Text~nodeを分割する$( %始端~node, %始端~offset )
【 %始端~offset が 0 でも分割されることになる。 】
◎ If range’s start node is a Text node, set referenceNode to the result of splitting it with offset range’s start offset. - ~IF[ %node ~EQ %基準~node ] ⇒ %基準~node ~SET %node の`次-同胞?$ ◎ If node is referenceNode, set referenceNode to its next sibling.
- ~IF[ %node の`親$ ~NEQ ~NULL ] ⇒ `~nodeを除去する$( %node ) ◎ If node’s parent is non-null, then remove node.
- %新-~offset ~LET [ %基準~node ~NEQ ~NULL ならば その`~index$ / ~ELSE_ %親 の`長さ$ ] ◎ Let newOffset be parent’s length if referenceNode is null, and referenceNode’s index otherwise.
- %新-~offset ~INCBY [ %node は`文書片$であるならば その`長さ$ / ~ELSE_ 1 ] ◎ Increase newOffset by node’s length if node is a DocumentFragment node, and one otherwise.
- %親 の中で`~nodeを子の前に前挿入する$( %node, %基準~node ) ◎ Pre-insert node into parent before referenceNode.
-
~IF[ %範囲o は`畳まれて$いる ] ⇒ %範囲o の`終端$ ~SET `境界点$( %親, %新-~offset )
【 畳まれていない場合の終端の位置は,`~nodeを子の前に前挿入する$(手続きの中で`~nodeを子の前に挿入する$)段階で適宜ずらされる。 】
◎ If range is collapsed, then set range’s end to (parent, newOffset).
@surroundContents(newParent) ~method~手続きは: ◎ The surroundContents(newParent) method, when invoked, must run these steps:
- ~IF[ ある非 $Text `~node$がコレに`部分的に包含され$ている ] ⇒ ~THROW `InvalidStateError$E ◎ If a non-Text node is partially contained in this, then throw an "InvalidStateError" DOMException.
-
~IF[ %newParent は $Document, $DocumentType, $DocumentFragment `~node$ のいずれかである ] ⇒ ~THROW `InvalidNodeTypeError$E ◎ If newParent is a Document, DocumentType, or DocumentFragment node, then throw an "InvalidNodeTypeError" DOMException.
注記: 歴史的な理由から、`文字~data~node$に対しては、この段では検査されず,後の段にて副作用とともに例外が投出される結果になる。 ◎ For historical reasons Text, ProcessingInstruction, and Comment nodes are not checked here and end up throwing later on as a side effect.
- %断片 ~LET コレの`中身を抽出-$rgした結果 ◎ Let fragment be the result of extracting this.
- ~IF[ %newParent は`子$を持つ ] ⇒ %newParent の`全~内容を~nodeで置換する$( ~NULL ) ◎ If newParent has children, then replace all with null within newParent.
- %newParent をコレの`中身に挿入-$rgする ◎ Insert newParent into this.
- %newParent に`~nodeを付加する$( %断片 ) ◎ Append fragment to newParent.
- %newParent を,コレの`中身として選択-$rgする ◎ Select newParent within this.
@detach() ~method~手続きは、何もしない。 ◎ The detach() method, when invoked, must do nothing.\
注記: この機能性( ^Range ~objを不能化する)は、除去された。 互換性のため存続はするが。 ◎ Its functionality (disabling a Range object) was removed, but the method itself is preserved for compatibility.
- %position = %range . $isPointInRange(node, offset)
- `境界点$( %node, %offset ) が %range 内に入る†かどうかを返す。
- %position = %range . $comparePoint(node, offset)
- `境界点$( %node, %offset ) が %range より前に位置する場合は ~MINUS 1 を, %range 内に入る†場合は 0 を, %range より後に位置する場合は 1 を 返す。【!*】 ◎ Returns −1 if the point is before the range, 0 if the point is in the range, and 1 if the point is after the range.
- 【† 境界点が %range のいずれかの境界点に一致する場合も,“入る” と見なされる。 】
- %intersects = %range . $intersectsNode(node)
- %range が %node と交わるかどうかを返す。 ◎ Returns whether range intersects node.
-
【 %node が %range に隣接している場合( %range の終端(始端)が %node の 外縁の 始端(終端)を指す境界点に一致する場合)は、“交わらない”。 例えば下図で `s^mk, `e^mk が %range の境界点を表すとするとき,図の~COLOR_Yが表す %node は交わらない。 】
`[|[y|(|.|)|]|s[|(|.|.|)|e[y|(|.|.|)|]|]|]^bpex【 一般に、 %node は %範囲o に (1) `包含され$ているとき, または (2) %範囲o の始端~node/終端~nodeいずれかの`広義先祖$であるとき、 “交わる”。 】
- $stringifier
- 範囲oを文字列~化した結果は、範囲oにより “選択-” されているすべての~textになる。
【 上のブロックに挙げた ^isPointInRange(), ^stringifier は、原文には存在しない,この訳による補完。 】
@isPointInRange(node, offset) ~method~手続きは: ◎ The isPointInRange(node, offset) method, when invoked, must run these steps:
- ~IF[ %node の`根$ ~NEQ コレの`根$rg ] ⇒ ~RET ~F ◎ If node’s root is different from this’s root, return false.
- ~IF[ `境界点$( %node, %offset ) は[[ コレの`始端$`より前$i ]~OR[ コレの`終端$`より後$i ]]] ⇒ ~RET ~F ◎ If (node, offset) is before start or after end, return false.
- ~RET ~T ◎ Return true.
@comparePoint(node, offset) ~method~手続きは: ◎ The comparePoint(node, offset) method, when invoked, must run these steps:
- ~IF[ %node の`根$ ~NEQ コレの`根$rg ] ⇒ ~THROW `WrongDocumentError$E ◎ If node’s root is different from this’s root, then throw a "WrongDocumentError" DOMException.
- ~IF[ `境界点$( %node, %offset ) は コレの`始端$`より前$i ] ⇒ ~RET ~MINUS 1 ◎ If (node, offset) is before start, return −1.
- ~IF[ `境界点$( %node, %offset ) は コレの`終端$`より後$i ] ⇒ ~RET 1 ◎ If (node, offset) is after end, return 1.
- ~RET 0 ◎ Return 0.
@intersectsNode(node) ~method~手続きは: ◎ The intersectsNode(node) method, when invoked, must run these steps:
- ~IF[ %親 ~EQ ~NULL 【!すなわち node は根】 ] ⇒ ~RET ~T ◎ If parent is null, return true.
- %offset ~LET %node の`~index$ ◎ Let offset be node’s index.
- ~IF[ `境界点$( %親, %offset ) は コレの`終端$`より前$i ]~AND[ `境界点$( %親, %offset ~PLUS 1 ) は コレの`始端$`より後$i 【!selectNode の結果】 ] ⇒ ~RET ~T ◎ If (parent, offset) is before end and (parent, offset plus 1) is after start, return true.
- ~RET ~F ◎ Return false.
@stringifier における`文字列~化の挙動$は: ◎ The stringification behavior must run these steps:
- %s ~LET 空~文字列 ◎ Let s be the empty string.
- ( %始端~node, %始端~offset, %終端~node, %終端~offset ) ~LET コレの ( `始端~node$, `始端~offset$, `終端~node$, `終端~offset$ ) ◎ ↓
-
~IF[ %始端~node は $Text `~node$である ]:
- ~IF[ %始端~node ~EQ %終端~node ] ⇒ ~RET %始端~node の`~data$内の[ %始端~offset から %終端~offset まで ]を成す部分文字列
- %s に次を付加する ⇒ %始端~node の`~data$内の[ %始端~offset から末尾まで ]を成す部分文字列
- %s に次を`連結-$した結果を付加する ⇒ `~tree順序$による,コレに`包含され$ているすべての $Text `~node$の`~data$ ◎ Append the concatenation of the data of all Text nodes that are contained in this, in tree order, to s.
- ~IF[ %終端~node は $Text `~node$である ] ⇒ %s に次を付加する ⇒ %終端~node の`~data$内の[ 先頭から %終端~offset まで ]を成す部分文字列 ◎ If this’s end node is a Text node, then append the substring of that node’s data from its start until this’s end offset to s.
- ~RET %s ◎ Return s.
注記: ^Range ~interfaceに対する拡張として、他の仕様にて `createContextualFragment()$m, `getClientRects()$m, `getBoundingClientRect()$m ~methodが定義されている。 `DOM-Parsing$r `CSSOM-VIEW$r ◎ The createContextualFragment(), getClientRects(), and getBoundingClientRect() methods are defined in other specifications. [DOM-Parsing] [CSSOM-VIEW]
6. 走査
[ $NodeIterator / $TreeWalker ]~objを利用すれば、`~node$`~tree$を~filterにかけながら走査できる。 ◎ NodeIterator and TreeWalker objects can be used to filter and traverse node trees.
各[ $NodeIterator / $TreeWalker ]~objには、次に挙げるものが結付けられる:
- `作動中~flag@tV
- 再入的な呼出nを避けるためにある。 初期~時は ~F とする。
- `根@tV
- 走査-対象にされる下位treeの根を与える,`~node$。
- `~whatToShow@tV
- どの型( $Node.nodeType )の~nodeを走査するかを指示する,整数~bitmask。 1 にされた~bitに対応する型の~nodeのみが~filterを “通過する” 。
- `~filter~callback@tV
- 対象を更に “濾過する” ~~条件を与える~callback, または ~NULL (濾過されない)。
【 [ 作動中~flag/値~型 ]以外の各項目の~~説明は、訳者による補足。 】
◎ Each NodeIterator and TreeWalker object has an associated active flag to avoid recursive invocations. It is initially unset. ◎ Each NodeIterator and TreeWalker object also has an associated root (a node), a whatToShow (a bitmask), and a filter (a callback).`走査器の中で~nodeを~filterにかける@ ときは、所与の ([ $NodeIterator / $TreeWalker ]~obj %走査器, `~node$ %node ) に対し,次を走らす: ◎ To filter a node node within a NodeIterator or TreeWalker object traverser, run these steps:
- ~IF[ %走査器 の`作動中~flag$tV ~EQ ~T ] ⇒ ~THROW `InvalidStateError$E ◎ If traverser’s active flag is set, then throw an "InvalidStateError" DOMException.
- %n ~LET %node の $Node.nodeType 属性~値 ~MINUS 1 ◎ Let n be node’s nodeType attribute value − 1.
- ~IF[ %走査器 の`~whatToShow$tV の %n 番の~bit( 0 番が最下位~bitとする) ~EQ 0 【! !((1 << (node.nodeType - 1)) & whatToShow) 】 ] ⇒ ~RET $NodeFilter.FILTER_SKIP ◎ If the nth bit (where 0 is the least significant bit) of traverser’s whatToShow is not set, then return FILTER_SKIP.
- ~IF[ %走査器 の`~filter~callback$tV ~EQ ~NULL ] ⇒ ~RET $NodeFilter.FILTER_ACCEPT ◎ If traverser’s filter is null, then return FILTER_ACCEPT.
- %走査器 の`作動中~flag$tV ~SET ~T ◎ Set traverser’s active flag.
-
%結果 ~LET 次を与える下で,`利用元~objの演算を~callする$ ⇒# %走査器 の`~filter~callback$tV, `acceptNode^l, « %node »
~callした結果,例外が投出されたときは、~catchして ⇒# %走査器 の`作動中~flag$tV ~SET ~F; ~THROW その例外
◎ Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ». If this throws an exception, then unset traverser’s active flag and rethrow the exception. - %走査器 の`作動中~flag$tV ~SET ~F ◎ Unset traverser’s active flag.
- ~RET %結果 ◎ Return result.
6.1. ^@NodeIterator ~interface
!! [`Exposed$=Window] interface @NodeIterator { [`SameObject$] ~RA $Node $root; ~RA $Node $referenceNode; ~RA $boolean $pointerBeforeReferenceNode; ~RA `unsigned long$ $whatToShow; ~RA $NodeFilter? $filter; $Node? $nextNode(); $Node? $previousNode(); $undefined $detach(); }; !注記: $NodeIterator ~objは、 $Document ~obj上の $Document.createNodeIterator() ~methodを利用して作成できる。 ◎ NodeIterator objects can be created using the createNodeIterator() method on Document objects.
各 $NodeIterator ~objには、次に挙げるものが結付けられる:
- `反復子~collection@
- 次のように設定された`~collection$ ⇒# `根$cL ~SET ~objの`根$tV, `~filter$cLは どの`~node$にも合致する
- `起点@tV
- `~node$。
- `起点の直前?@tV
- 真偽値。
- 【 概念的には,これと`起点$tVの組により、[ `反復子で走査する$ときに どの~nodeから探索し始めるか ]を指す,~pointerが表現される。 `起点$tV (初期~時には先頭の~nodeである`根$tVにされる)が “現在の” ~nodeを表し、`起点の直前?$tV (初期~時には ~T にされる)に応じて、~pointerは,現在の~nodeの “直前” ( ~T )か “直後” ( ~F )を指す(したがって、初期~時の~pointerは`根$tVの直前を指す)。 】
注記: 前に言及したように、 $NodeIterator ~objには[ `作動中~flag$tV, `根$tV, `~whatToShow$tV, `~filter~callback$tV ]も結付けられる。 ◎ As mentioned earlier, NodeIterator objects have an associated active flag, root, whatToShow, and filter as well.
`前除去-時の手続き@ は、所与の ( $NodeIterator %反復子, `~node$ %除去される~node ) に対し,次に従う: ◎ The NodeIterator pre-removing steps given a nodeIterator and toBeRemovedNode, are as follows:
- ~IF[ %除去される~node は %反復子 の`起点$tVの`広義先祖$でない ]~OR[ %除去される~node ~EQ %反復子 の`根$tV ] ⇒ ~RET ◎ If toBeRemovedNode is not an inclusive ancestor of nodeIterator’s reference, or toBeRemovedNode is nodeIterator’s root, then return.
-
~IF[ %反復子 の`起点の直前?$tV ~EQ ~T ]: ◎ If nodeIterator’s pointer before reference is true, then:
-
%次- ~LET 次をすべて満たす`~node$のうち,`最初のもの?$:
- %除去される~node に`後続-$する
- %反復子 の`根$tVの`広義子孫$である
- %除去される~node の`広義子孫$でない
- ~IF[ %次- ~NEQ ~NULL ] ⇒# %反復子 の`起点$tV ~SET %次-; ~RET ◎ If next is non-null, then set nodeIterator’s reference to next and return.
- %反復子 の`起点の直前?$tV ~SET ~F ◎ Otherwise, set nodeIterator’s pointer before reference to false. ◎ Steps are not terminated here.
-
- %前-同胞 ~LET %除去される~node の`前-同胞?$ ◎ ↓
- %反復子 の`起点$tV ~SET %前-同胞 に応じて ⇒# ~NULL ならば %除去される~node の`親$ / ~ELSE_ %前-同胞 の`広義子孫$のうち `最後のもの?$ ◎ Set nodeIterator’s reference to toBeRemovedNode’s parent, if toBeRemovedNode’s previous sibling is null, and to the inclusive descendant of toBeRemovedNode’s previous sibling that appears last in tree order otherwise.
`反復子で走査する@ ときは、所与の ( $NodeIterator ~obj %反復子, %方向 ~IN { `順^i, `逆^i } ) に対し,次を走らす: ◎ To traverse, given a NodeIterator object iterator and a direction direction, run these steps:
- %node ~LET %反復子 の`起点$tV ◎ Let node be iterator’s reference.
- %直前? ~LET %反復子 の`起点の直前?$tV ◎ Let beforeNode be iterator’s pointer before reference.
- %collection ~LET %反復子 の`反復子~collection$ ◎ ↓
-
~WHILE 無条件: ◎ While true:
-
~IF[ %方向 ~EQ `順^i ]: ◎ Branch on direction: ◎ next
-
~IF[ %直前? ~EQ ~F ]: ◎ If beforeNode is false, then\
- %node ~SET %collection の中で %node に`後続-$する`~node$のうち,`最初のもの?$ ◎ set node to the first node following node in iterator’s iterator collection.\
- ~IF[ %node ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If there is no such node, then return null.
- ~ELSE ⇒ %直前? ~SET ~F ◎ If beforeNode is true, then set it to false.
-
-
~ELSE( %方向 ~EQ `逆^i ): ◎ previous
-
~IF[ %直前? ~EQ ~T ]: ◎ If beforeNode is true, then\
- %node ~SET %collection の中で %node に`先行-$する`~node$のうち,`最後のもの?$ ◎ set node to the first node preceding node in iterator’s iterator collection.\
- ~IF[ %node ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If there is no such node, then return null.
- ~ELSE ⇒ %直前? ~SET ~T ◎ If beforeNode is false, then set it to true.
-
- ~IF[ `走査器の中で~nodeを~filterにかける$( %反復子, %node ) ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒ ~BREAK ◎ Let result be the result of filtering node within iterator. ◎ If result is FILTER_ACCEPT, then break.
-
- %反復子 の`起点$tV ~SET %node ◎ Set iterator’s reference to node.
- %反復子 の`起点の直前?$tV ~SET %直前? ◎ Set iterator’s pointer before reference to beforeNode.
- ~RET %node ◎ Return node.
【 走査の方向が前回と逆向きに切り替わった場合、探索は,前回の走査による “現在の” ~node( `起点$tV )から開始されることに注意(その次-/前-~nodeからではなく)。 探索の結果,`~filter$cLに合致する~nodeが見出されなかった場合、`起点$tVは変更されない。 見出された場合、 `起点$tV は,新たに見出された~nodeにされ, `起点の直前?$tV ( “現在の” 走査-方向)は,渡された %方向 を反映するようにされる( ~F が `順^i 方向に対応する)。 】
@detach() ~method~手続きは、何もしない。 ◎ The detach() method, when invoked, must do nothing.\
注記: この機能性( ^NodeIterator ~objを不能化する)は、除去された。 互換性のため存続はするが。 ◎ Its functionality (disabling a NodeIterator object) was removed, but the method itself is preserved for compatibility.
6.2. ^@TreeWalker ~interface
!! [`Exposed$=Window] interface @TreeWalker { [`SameObject$] ~RA $Node $root; ~RA `unsigned long$ $whatToShow; ~RA $NodeFilter? $filter; attribute $Node $currentNode; $Node? $parentNode(); $Node? $firstChild(); $Node? $lastChild(); $Node? $previousSibling(); $Node? $nextSibling(); $Node? $previousNode(); $Node? $nextNode(); }; !注記: $TreeWalker ~objは、 $Document ~obj上の $Document.createTreeWalker() ~methodを利用して作成できる。 ◎ TreeWalker objects can be created using the createTreeWalker() method on Document objects.
各 $TreeWalker ~objには、 `現-~node@tV ( `~node$ )が結付けられる。 ◎ Each TreeWalker object has an associated current (a node).
注記: 前に言及したように、 $TreeWalker ~objには[ `根$tV, `~whatToShow$tV, `~filter~callback$tV ]も結付けられる。 ◎ As mentioned earlier TreeWalker objects have an associated root, whatToShow, and filter as well.
@parentNode() ~method~手続きは: ◎ The parentNode() method, when invoked, must run these steps:
- %node ~LET コレの`現-~node$tV ◎ Let node be this’s current.
-
~WHILE[ %node ~NEQ ~NULL ]~AND[ %node ~NEQ コレの`根$tV ]: ◎ While node is non-null and is not this’s root:
- %node ~SET %node の`親$ ◎ Set node to node’s parent.
- ~IF[ %node ~NEQ ~NULL ]~AND[ `走査器の中で~nodeを~filterにかける$( コレ, %node ) ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒# コレの`現-~node$tV ~SET %node; ~RET %node ◎ If node is non-null and filtering node within this returns FILTER_ACCEPT, then set this’s current to node and return node.
- ~RET ~NULL ◎ Return null.
`子たちを走査する@ ときは、所与の ( %walker, %向き ~IN { `最初から^i, `最後から^i } ) に対し,次を走らす: ◎ To traverse children, given a walker and type, run these steps:
- %node ~LET %walker の`現-~node$tV ◎ Let node be walker’s current.
- %node ~SET %向き に応じて ⇒# `最初から^i ならば %node の`最初の子?$ / `最後から^i ならば %node の`最後の子?$ ◎ Set node to node’s first child if type is first, and node’s last child if type is last.
-
~WHILE[ %node ~NEQ ~NULL ]: ◎ While node is non-null:
- %結果 ~LET `走査器の中で~nodeを~filterにかける$( %walker, %node ) ◎ Let result be the result of filtering node within walker.
- ~IF[ %結果 ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒# %walker の`現-~node$tV ~SET %node; ~RET %node ◎ If result is FILTER_ACCEPT, then set walker’s current to node and return node.
-
~IF[ %結果 ~EQ $NodeFilter.FILTER_SKIP ]: ◎ If result is FILTER_SKIP, then:
- %子 ~LET %向き に応じて ⇒# `最初から^i ならば %node の`最初の子?$ / `最後から^i ならば %node の`最後の子?$ ◎ Let child be node’s first child if type is first, and node’s last child if type is last.
- ~IF[ %子 ~NEQ ~NULL ] ⇒# %node ~SET %子; ~CONTINUE ◎ If child is non-null, then set node to child and continue.
-
~WHILE[ %node ~NEQ ~NULL ]: ◎ While node is non-null:
- %同胞 ~LET %向き に応じて ⇒# `最初から^i ならば %node の`次-同胞?$ / `最後から^i ならば %node の`前-同胞?$ ◎ Let sibling be node’s next sibling if type is first, and node’s previous sibling if type is last.
- ~IF[ %同胞 ~NEQ ~NULL ] ⇒# %node ~SET %同胞; ~BREAK ◎ If sibling is non-null, then set node to sibling and break.
- %親 ~LET %node の`親$ ◎ Let parent be node’s parent.
- ~IF[ %親 ~IN { ~NULL, %walker の`根$tV, %walker の`現-~node$tV } ] ⇒ ~RET ~NULL ◎ If parent is null, walker’s root, or walker’s current, then return null.
- %node ~SET %親 ◎ Set node to parent.
`同胞たちを走査する@ ときは、所与の ( %walker, %向き ~IN { `順^i, `逆^i } ) に対し,次を走らす: ◎ To traverse siblings, given a walker and type, run these steps:
- ~IF[ %node ~EQ %walker の`根$tV ] ⇒ ~RET ~NULL ◎ If node is root, then return null.
-
- %同胞 ~LET %向き に応じて ⇒# `順^i ならば %node の`次-同胞?$ / `逆^i ならば %node の`前-同胞?$ ◎ Let sibling be node’s next sibling if type is next, and node’s previous sibling if type is previous.
-
~WHILE[ %同胞 ~NEQ ~NULL ]: ◎ While sibling is non-null:
- %node ~SET %同胞 ◎ Set node to sibling.
- %同胞 ~SET %向き に応じて ⇒# `順^i ならば %node の`最初の子?$ / `逆^i ならば %node の`最後の子?$ ◎ Set sibling to node’s first child if type is next, and node’s last child if type is previous.
- ~IF[ %結果 ~EQ $NodeFilter.FILTER_REJECT ]~OR[ %同胞 ~EQ ~NULL ] ⇒ %同胞 ~SET %向き に応じて ⇒# `順^i ならば %node の`次-同胞?$ / `逆^i ならば %node の`前-同胞?$ ◎ If result is FILTER_REJECT or sibling is null, then set sibling to node’s next sibling if type is next, and node’s previous sibling if type is previous.
- %node ~SET %node の`親$ ◎ Set node to node’s parent.
- ~IF[ %node ~IN { ~NULL, %walker の`根$tV } ] ⇒ ~RET ~NULL ◎ If node is null or walker’s root, then return null.
- ~IF[ `走査器の中で~nodeを~filterにかける$( コレ, %node ) ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒ ~RET ~NULL ◎ If the return value of filtering node within walker is FILTER_ACCEPT, then return null.
@previousNode() ~method~手続きは: ◎ The previousNode() method, when invoked, must run these steps:
-
~WHILE[ %node ~NEQ コレの`根$tV ]: ◎ While node is not this’s root:
- %同胞 ~LET %node の`前-同胞?$ ◎ Let sibling be node’s previous sibling.
-
~WHILE[ %同胞 ~NEQ ~NULL ]: ◎ While sibling is non-null:
- %node ~SET %同胞 ◎ Set node to sibling.
- %結果 ~LET `走査器の中で~nodeを~filterにかける$( コレ, %node ) ◎ Let result be the result of filtering node within this.
-
~WHILE[ %結果 ~NEQ $NodeFilter.FILTER_REJECT ]~AND[ %node は`子$を持つ ]: ◎ While result is not FILTER_REJECT and node has a child:
- %node ~SET %node の`最後の子?$ ◎ Set node to node’s last child.
- %結果 ~SET `走査器の中で~nodeを~filterにかける$( コレ, %node ) ◎ Set result to the result of filtering node within this.
- ~IF[ %結果 ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒# コレの`現-~node$tV ~SET %node; ~RET %node ◎ If result is FILTER_ACCEPT, then set this’s current to node and return node.
- %同胞 ~SET %node の`前-同胞?$ ◎ Set sibling to node’s previous sibling.
- ~IF[ %node ~EQ コレの`根$tV ]~OR[ %node の`親$ ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If node is this’s root or node’s parent is null, then return null.
- %node ~SET %node の`親$ ◎ Set node to node’s parent.
- ~IF[ `走査器の中で~nodeを~filterにかける$( コレ, %node ) ~EQ $NodeFilter.FILTER_ACCEPT ] ⇒# コレの`現-~node$tV ~SET %node; ~RET %node ◎ If the return value of filtering node within this is FILTER_ACCEPT, then set this’s current to node and return node.
@nextNode() ~method~手続きは: ◎ The nextNode() method, when invoked, must run these steps:
- %結果 ~LET $NodeFilter.FILTER_ACCEPT ◎ Let result be FILTER_ACCEPT.
-
-
- %node ~SET %node の`最初の子?$ ◎ Set node to its first child.
- %同胞 ~LET ~NULL ◎ Let sibling be null.
- %temporary ~LET %node ◎ Let temporary be node.
-
~WHILE[ %temporary ~NEQ ~NULL ]: ◎ While temporary is non-null:
- ~IF[ %temporary ~EQ コレの`根$tV ] ⇒ ~RET ~NULL ◎ If temporary is this’s root, then return null.
- %同胞 ~SET %temporary の`次-同胞?$ ◎ Set sibling to temporary’s next sibling.
- ~IF[ %同胞 ~NEQ ~NULL ] ⇒# %node ~SET %同胞; ~BREAK ◎ If sibling is non-null, then set node to sibling and break.
- %temporary ~SET %temporary の`親$ ◎ Set temporary to temporary’s parent.
-
6.3. ^@NodeFilter ~interface
!! [`Exposed$=Window] callback interface @NodeFilter { //$acceptNode()
用の定数
const `unsigned short$ $FILTER_ACCEPT = 1;
const `unsigned short$ $FILTER_REJECT = 2;
const `unsigned short$ $FILTER_SKIP = 3;
// `~whatToShow$tV 用の定数
const `unsigned long$ $SHOW_ALL = 0xFFFFFFFF;
const `unsigned long$ $SHOW_ELEMENT = 0x1;
const `unsigned long$ $SHOW_ATTRIBUTE = 0x2;
const `unsigned long$ $SHOW_TEXT = 0x4;
const `unsigned long$ $SHOW_CDATA_SECTION = 0x8;
const `unsigned long$ @SHOW_ENTITY_REFERENCE = 0x10; //
const `unsigned long$ @SHOW_ENTITY = 0x20; //
const `unsigned long$ $SHOW_PROCESSING_INSTRUCTION = 0x40;
const `unsigned long$ $SHOW_COMMENT = 0x80;
const `unsigned long$ $SHOW_DOCUMENT = 0x100;
const `unsigned long$ $SHOW_DOCUMENT_TYPE = 0x200;
const `unsigned long$ $SHOW_DOCUMENT_FRAGMENT = 0x400;
const `unsigned long$ @SHOW_NOTATION = 0x800; //
`unsigned short$ @acceptNode($Node %node);
};
!
注記: $NodeFilter ~objは、[ $NodeIterator / $TreeWalker ]用の`~filter~callback$tVとして利用できる。 また、それら用の`~whatToShow$tVとして~bitmask定数を供する。 $NodeFilter ~objは、概して,~JS関数として実装される。 ◎ NodeFilter objects can be used as filter for NodeIterator and TreeWalker objects and also provide constants for their whatToShow bitmask. A NodeFilter object is typically implemented as a JavaScript function.
`~filter~callback$tVの返り値には、次に挙げる定数を利用できる(括弧内は数-値) 【各~項目の~~説明は、訳者による補足】:
- @FILTER_ACCEPT (1) ⇒ ~nodeは~filterを “通過する”。
- @FILTER_REJECT (2) ⇒ $NodeIterator に利用されている下では、 $FILTER_SKIP と同じ結果になる。 $TreeWalker に利用されている下では、~nodeはその子孫も含めて “濾過される”。
- @FILTER_SKIP (3) ⇒ ~node自身は “濾過される” が、その子孫は,依然として~filterの対象になり得る。
`~whatToShow$tV用には、次に挙げる定数を利用できる(括弧内は数-値): ◎ These constants can be used for whatToShow:
- @SHOW_ALL (4294967295 ~EQ 0xFFFFFFFF)
- @SHOW_ELEMENT (1)
- @SHOW_ATTRIBUTE (2)
- @SHOW_TEXT (4)
- @SHOW_CDATA_SECTION (8)
- @SHOW_PROCESSING_INSTRUCTION (64 ~EQ 0x40)
- @SHOW_COMMENT (128 ~EQ 0x80)
- @SHOW_DOCUMENT (256 ~EQ 0x100)
- @SHOW_DOCUMENT_TYPE (512 ~EQ 0x200)
- @SHOW_DOCUMENT_FRAGMENT (1024 ~EQ 0x400)
7. ~token集合
Yes, the name $DOMTokenList is an unfortunate legacy mishap.
7.1. ^@DOMTokenList ~interface
!! [`Exposed$=Window] interface @DOMTokenList { ~RA `unsigned long$ $length; getter $DOMString? $item(`unsigned long$ %index); $boolean $contains($DOMString %token); [`CEReactions$] $undefined $add($DOMString... %tokens); [`CEReactions$] $undefined $remove($DOMString... %tokens); [`CEReactions$] $boolean $toggle($DOMString %token, optional $boolean %force); [`CEReactions$] $boolean $replace($DOMString %token, $DOMString %newToken); $boolean $supports($DOMString %token); [`CEReactions$] @stringifier attribute $DOMString $value; iterable<$DOMString>; }; !各 $DOMTokenList には、次に挙げるものが結付けられる:
- `~token集合@tL
- 一連の~tokenからなる`有順序~集合$ — 初期~時は空とする。
- `要素@tL
- `要素$。
- `属性oの局所~名@tL
- `属性o$の`局所~名$a。
`適用-可能な仕様$は、個々の`局所~名$aに対し,それが `~supportする~token集合@tL を $DOMTokenList 用に定義してもヨイ — これは、一連の~tokenからなる集合であり,特に指定されない限り ε (未定義)とする。 ◎ Specifications may define supported tokens for a DOMTokenList's associated attribute’s local name.
$DOMTokenList ~obj %O 上で `~tokenを検証する@ ときは、所与の ( %~token ) に対し,次を走らす: ◎ A DOMTokenList object’s validation steps for a given token are:
- %~token集合 ~LET %O の`属性oの局所~名$tLが`~supportする~token集合$tL ◎ ↓
- ~IF[ %~token集合 ~EQ ε ] ⇒ ~THROW `TypeError$E ◎ If the associated attribute’s local name does not define supported tokens, throw a TypeError.
- ~RET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ `~ASCII小文字~化する$( %~token ) ~IN %~token集合 ◎ Let lowercase token be a copy of token, in ASCII lowercase. ◎ If lowercase token is present in supported tokens, return true. ◎ Return false.
所与の $DOMTokenList ~obj %O 対し, ( %要素, %名前 ) は ( %O の`要素$tL, %O の`属性oの局所~名$tL ) とするとき: ◎ ↓
-
%O の `更新~手続き@tL は、次を走らす: ◎ A DOMTokenList object’s update steps are:
- ~IF[ %要素 の`属性o~list$は空である ]~AND[ %O の`~token集合$tLは空である ] ⇒ ~RET ◎ If the associated element does not have an associated attribute and token set is empty, then return.
- %要素 の`属性o値を設定する$( %名前, [ %O の`~token集合$tLを`有順序~集合 直列化器$にかけた結果 ] ) ◎ Set an attribute value for the associated element using associated attribute’s local name and the result of running the ordered set serializer for token set.
- %O の `直列化-手続き@tL は、次の結果を返す ⇒ %要素 の`属性o値を取得する$( %名前 ) ◎ A DOMTokenList object’s serialize steps are to return the result of running get an attribute value given the associated element and the associated attribute’s local name.
-
%要素 上の`属性o変更-時の手続き$は、次で与えられる: ◎ A DOMTokenList object has these attribute change steps for its associated element:
-
~IF[ %局所~名 ~EQ %名前 ]~AND[ %~ns ~EQ ~NULL ]:
- ~IF[ %値 ~EQ ~NULL ] ⇒ %O の`~token集合$tLを`空にする$
- ~ELSE ⇒ %O の`~token集合$tL ~SET %値 を`有順序~集合 構文解析器$にかけた結果
-
-
%O の作成-時には、次を走らす: ◎ When a DOMTokenList object is created, then:
- %値 ~LET %要素 の`属性o値を取得する$( %名前 ) ◎ Let element be associated element. ◎ Let localName be associated attribute’s local name. ◎ Let value be the result of getting an attribute value given element and localName.
- 次を渡して, %要素 上の`属性o変更-時の手続き$を走らす ⇒ ( %名前, %値, %値, ~NULL ) ◎ Run the attribute change steps for element, localName, value, value, and null.
- %tokenlist . $length
- ~tokenの個数を返す。 ◎ Returns the number of tokens.
- %tokenlist . $item(index)
- %tokenlist[%index]
- %index 番の~tokenを返す。 ◎ Returns the token with index index.
- %tokenlist . $contains(token)
- %token が在れば~T を, 無ければ~F を返す。 ◎ Returns true if token is present, and false otherwise.
- %tokenlist . $add(tokens…)
- 渡された引数のうち,まだ無いものを追加する。 ◎ Adds all arguments passed, except those already present.
- 下記に該当する場合、例外が投出される。 ◎ Throws a "SyntaxError" DOMException if one of the arguments is the empty string. ◎ Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
- %tokenlist . $remove(tokens…)
- 渡された引数のそれぞれを(もし在れば)除去する。 ◎ Removes arguments passed, if they are present.
- ◎ Throws a "SyntaxError" DOMException if one of the arguments is the empty string. ◎ Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
- %tokenlist . $toggle(token [, force])
-
%force に応じて:
- 省略されているならば、 %token の有無を “切り替える”。 すなわち、 %token がすでに在れば除去し,無ければ追加する。
- ~T ならば、 %token を追加する( $add() と同じ)。
- ~F ならば、 %token を除去する( $remove() と同じ)。
その結果、 %token が残っていれば ~T を, 無くなっていれば ~F を返す。
◎ If force is not given, "toggles" token, removing it if it’s present and adding it if it’s not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()). ◎ Returns true if token is now present, and false otherwise. - ◎ Throws a "SyntaxError" DOMException if token is empty. ◎ Throws an "InvalidCharacterError" DOMException if token contains any spaces.
- %tokenlist . $replace(token, newToken)
-
- %token を %newToken に置換する。 ◎ Replaces token with newToken.
- %token が %newToken に置換されたなら ~T, 置換されなかったなら ~F を返す。 ◎ Returns true if token was replaced with newToken, and false otherwise.
- ◎ Throws a "SyntaxError" DOMException if one of the arguments is the empty string. ◎ Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
- (例外)
-
上の各種~methodに所与の文字列~引数のいずれかが,次に該当する場合、対応する例外が投出される:
- 空~文字列の場合: `SyntaxError$E
- `~ASCII空白$を含む場合: `InvalidCharacterError$E
- %tokenlist . $supports(token)
- `属性oの局所~名$tLが`~supportする~token集合$tLに %token が含まれて[ いれば ~T / いなければ ~F ]を返す。 ◎ Returns true if token is in the associated attribute’s supported tokens. Returns false otherwise.
- `~supportする~token集合$tLが定義されていない場合、 `TypeError$E が投出される。 ◎ Throws a TypeError if the associated attribute has no supported tokens defined.
- %tokenlist . $value
- 結付けられている`~token集合$tLを文字列として返す。 ◎ Returns the associated set as string.
- 設定して結付けられている属性を変更できる。 ◎ Can be set, to change the associated attribute.
$DOMTokenList ~obj %O が`~supportする~prop~index$は、 0 以上[ %O の`~token集合$tLの`~size$ ]未満とする。 ◎ The object’s supported property indices are the numbers in the range zero to object’s token set’s size minus one, unless token set is empty, in which case there are no supported property indices.
@item(index) ~method~手続きは: ◎ The item(index) method, when invoked, must run these steps:
- ~IF[ %index ~NIN { コレが`~supportする~prop~index$ } ] ⇒ ~RET ~NULL ◎ If index is equal to or greater than this’s token set’s size, then return null.
- ~RET コレの`~token集合$tL[ %index ] ◎ Return this’s token set[index].
`~tokenを検査する@ ときは、所与の ( %token ) に対し,次を走らす:
- ~IF[ %token ~EQ 空~文字列 ] ⇒ ~THROW `SyntaxError$E
- ~IF[ %token は`~ASCII空白$を含んでいる ] ⇒ ~THROW `InvalidCharacterError$E
@add(tokens…) ~method~手続きは: ◎ The add(tokens…) method, when invoked, must run these steps:
- %tokens 内の ~EACH( %token ) に対し,与えられた順に ⇒ `~tokenを検査する$( %token ) ◎ For each token in tokens: • If token is the empty string, then throw a "SyntaxError" DOMException. • If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- %tokens 内の ~EACH( %token ) に対し ⇒ コレの`~token集合$tLに %token を`付加する$set ◎ For each token in tokens, append token to this’s token set.
- コレの`更新~手続き$tLを走らす ◎ Run the update steps.
@remove(tokens…) ~method~手続きは: ◎ The remove(tokens…) method, when invoked, must run these steps:
- %tokens 内の各 %token に対し ⇒ コレの`~token集合$tLから %token を`除去する$ ◎ For each token in tokens, remove token from this’s token set.
@toggle(token, force) ~method~手続きは: ◎ The toggle(token, force) method, when invoked, must run these steps:
- `~tokenを検査する$( %token ) ◎ If token is the empty string, then throw a "SyntaxError" DOMException. ◎ If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
-
~IF[ %token ~IN コレの`~token集合$tL ]: ◎ If this’s token set[token] exists, then:
-
~IF[ %force は与えられてない ]~OR[ %force ~EQ ~F ]:
- コレの`~token集合$tLから %token を`除去する$
- コレの`更新~手続き$tLを走らす
- ~RET ~F
- ~RET ~T ◎ Return true.
-
-
~IF[ %force は与えられてない ]~OR[ %force ~EQ ~T ]:
- コレの`~token集合$tLに %token を`付加する$set
- コレの`更新~手続き$tLを走らす
- ~RET ~T
- ~RET ~F ◎ Return false.
注記: ~web互換性のため、 $toggle() に対しては,`更新~手続き$tLを常に走らすとは限らない。 ◎ The update steps are not always run for toggle() for web compatibility.
@replace(token, newToken) ~method~手続きは: ◎ The replace(token, newToken) method, when invoked, must run these steps:
- ~IF[ %token ~EQ 空~文字列 ]~OR[ %newToken ~EQ 空~文字列 ] ⇒ ~THROW `SyntaxError$E ◎ If either token or newToken is the empty string, then throw a "SyntaxError" DOMException.
- ~IF[ %token は`~ASCII空白$を含んでいる ]~OR[ %newToken は`~ASCII空白$を含んでいる ] ⇒ ~THROW `InvalidCharacterError$E ◎ If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- ~IF[ %token ~NIN コレの`~token集合$tL ] ⇒ ~RET ~F ◎ If this’s token set does not contain token, then return false.
- コレの`~token集合$tL内で %token を %newToken に`置換する$setする ◎ Replace token in this’s token set with newToken.
- ~RET ~T ◎ Return true.
注記: ~web互換性のため、 $replace() に対しては,`更新~手続き$tLを常に走らすとは限らない。 ◎ The update steps are not always run for replace() for web compatibility.
【 最初と二番目の段は、 %token, %newToken の順に`~tokenを検査する$のとは,挙動が異なる。 】
8. ~XPath
`DOM Level 3 XPath^cite は、 `XPath 1.0^cite 式を評価するための~APIを定義した。 これらの~APIは、広く実装されてはいるが,保守されていない。 各種~interface定義は、 `Web IDL^cite が変更されるに伴い更新できるよう,ここに保守される。 これらの~APIの完全な定義は、引き続き必要とされ, whatwg/dom#67 にて その作業[ を追跡できる/に貢献できる ]。 `DOM-Level-3-XPath$r `XPath$r `WEBIDL$r ◎ DOM Level 3 XPath defined an API for evaluating XPath 1.0 expressions. These APIs are widely implemented, but have not been maintained. The interface definitions are maintained here so that they can be updated when Web IDL changes. Complete definitions of these APIs remain necessary and such work is tracked and can be contributed to in whatwg/dom#67. [DOM-Level-3-XPath] [XPath] [WEBIDL]
8.1. ^@XPathResult ~interface
!! [`Exposed$=Window] interface @XPathResult { const `unsigned short$ @ANY_TYPE = 0; const `unsigned short$ @NUMBER_TYPE = 1; const `unsigned short$ @STRING_TYPE = 2; const `unsigned short$ @BOOLEAN_TYPE = 3; const `unsigned short$ @UNORDERED_NODE_ITERATOR_TYPE = 4; const `unsigned short$ @ORDERED_NODE_ITERATOR_TYPE = 5; const `unsigned short$ @UNORDERED_NODE_SNAPSHOT_TYPE = 6; const `unsigned short$ @ORDERED_NODE_SNAPSHOT_TYPE = 7; const `unsigned short$ @ANY_UNORDERED_NODE_TYPE = 8; const `unsigned short$ @FIRST_ORDERED_NODE_TYPE = 9; ~RA `unsigned short$ @resultType; ~RA `unrestricted double$ @numberValue; ~RA $DOMString @stringValue; ~RA $boolean @booleanValue; ~RA $Node? @singleNodeValue; ~RA $boolean @invalidIteratorState; ~RA `unsigned long$ @snapshotLength; $Node? @iterateNext(); $Node? @snapshotItem(`unsigned long$ %index); }; !8.2. ^@XPathExpression ~interface
!! [`Exposed$=Window] interface @XPathExpression { // XPathResult.ANY_TYPE = 0 XPathResult @evaluate($Node %contextNode, optional `unsigned short$ %type = 0, optional $XPathResult? %result = null); }; !8.3. ^XPathEvaluatorBase ~mixin
!! callback interface @@XPathNSResolver { $DOMString? @lookupNamespaceURI($DOMString? %prefix); }; interface mixin @@XPathEvaluatorBase { [NewObject] @XPathExpression @createExpression($DOMString %expression, optional $XPathNSResolver? %resolver = null); $XPathNSResolver @createNSResolver($Node %nodeResolver); // XPathResult.ANY_TYPE = 0 $XPathResult @evaluate($DOMString %expression, $Node %contextNode, optional $XPathNSResolver? %resolver = null, optional `unsigned short$ %type = 0, optional $XPathResult? %result = null); }; $Document includes $XPathEvaluatorBase; !8.4. ^@XPathEvaluator ~interface
!! [`Exposed$=Window] interface @XPathEvaluator { `XPathEvaluator@mc(); }; $XPathEvaluator includes $XPathEvaluatorBase; !注記: 歴史的な理由から、 $XPathEvaluator を構築することも, $Document 上で同じ~methodに~accessすることもできる。 ◎ For historical reasons you can both construct XPathEvaluator and access the same methods on Document.
9. 歴史的なもの
次に挙げる~interfaceは、除去された: ◎ These interfaces have been removed:
- @DOMConfiguration
- @DOMError
- @DOMErrorHandler
- @DOMImplementationList
- @DOMImplementationSource
- @DOMLocator
- @DOMObject
- @DOMUserData
- @Entity
- @EntityReference
- @MutationEvent
- @MutationNameEvent
- @NameList
- @Notation
- @RangeException
- @TypeInfo
- @UserDataHandler
次に挙げる~interface~memberは、除去された: ◎ And these interface members have been removed:
- $@Attr
- @schemaTypeInfo
- @isId
- $@Document
- @createEntityReference()
- @xmlEncoding
- @xmlStandalone
- @xmlVersion
- @strictErrorChecking
- @domConfig
- @normalizeDocument()
- @renameNode()
- @xmlEncoding
- $@DocumentType
- @entities
- @notations
- @internalSubset
- @notations
- $@DOMImplementation
- @getFeature()
- $@Element
- @schemaTypeInfo
- @setIdAttribute()
- @setIdAttributeNS()
- @setIdAttributeNode()
- @setIdAttribute()
- $@Node
- @isSupported
- @getFeature()
- @getUserData()
- @setUserData()
- @getFeature()
- $@NodeIterator
- @expandEntityReferences
- $@Text
- @isElementContentWhitespace
- @replaceWholeText()
- $@TreeWalker
- @expandEntityReferences
謝辞
年月に渡り、 DOM を相互運用可能にするために,たくさんの方々が助力され、この標準の目標へ近付けてきた。 同様に,この標準の今日の姿は、多くの方々からの助力により作り上げられている。 ◎ There have been a lot of people that have helped make DOM more interoperable over the years and thereby furthered the goals of this standard. Likewise many people have helped making this standard what it is today.
`_acks1@