limited to only non-negative numbers greater than zero with fallback

反映 (DOM)

[4] IDL属性内容属性反映する (reflect) とは、 IDL属性取得内容属性の値を返し、 設定内容属性の値を変更するようなものをいいます。

仕様書

文脈

[7] IDL属性のデータ型と内容属性の値の種類により、次のバリエーションがあります。

[20] 次の内容属性URL として反映する IDL属性があります。

[53] かつてはHTML要素itemid 属性もありました。

[23] 次の内容属性URL (valid non-empty URL potentially surrounded by spaces) として反映する IDL属性があります。

[41] 列挙属性IDL属性の関係は、 列挙属性の項を参照。

[18] 次の IDL属性は、反映の処理と当該属性専用の処理が組み合わさっています。

[57] 次のIDL属性は、一部または全部の処理が反映と似ていますが、 反映と異なる定義となっています。

[21] 次の内容属性は、URL分解属性があります。

[22] 仕様書の用語としては反映とは異なりますが、 その特殊形に当たります。 URLUtils 参照。

[33] CSSStyleDeclaration インターフェイスIDL属性は、 CSS特性に対応するもので、実質的には反映と同じものですが、 仕様書の用語としては異なるものになっています。

[145] HTMLElement としての反映は、定義はされていますが、 実際には使われていません。

[146] 近いものとして HTMLInputElementlistHTMLLabelElementcontrol がありますが、どちらも挙動が反映と異なります。

処理

[133] 内容属性内容属性反映する DOMTokenListIDL属性IDL属性は、 すべて読み取り専用で、 SameObject となっています。 IDL属性を持つ要素要素は、次のような DOMTokenList オブジェクトを保持し、IDL属性取得器はこのオブジェクトを返さなければなりません >>6

[134] DOMTokenList
関連付けられた要素
要素
関連付けられた属性局所名
内容属性局所名

[132] それ以外の場合は、次のようにします。

[69] IDL属性IDL属性内容属性内容属性取得器は、 次のようにしなければなりません >>6

  1. [71] 文脈オブジェクト属性リスト内容属性が含まれなければ、 IDL属性により、
    列挙属性欠値既定値と同じキーワードあり
    そのキーワードの正準形を返します。
    USVStringDOMString
    空文字列を返します。
    boolean
    を返します。
    longunsigned longdoubleunrestricted double
    内容属性の既定値を返します。
    DOMString?
    null を返します。
  2. [73] それ以外なら、
    1. [78] を、文脈オブジェクト内容属性属性に設定します。
    2. [74] IDL属性により、
      USVString
      1. [26] 内容属性の値が URL と定義されている場合、
        1. [75] 結果を、文脈オブジェクト節点文書に対してURLとして構文解析した結果に設定します。
        2. [76] 結果失敗なら、
          1. [77] USVString変換した結果を返します。
        3. [79] それ以外なら、
          1. [80] 結果結果URL文字列を返します。
      2. [27] それ以外の場合、
        1. [28] を返します。
      DOMString
      1. [29] 内容属性列挙属性limited to only known valuesの場合、
        1. [83] 状態を、文脈オブジェクト内容属性状態に設定します。
        2. [84] 状態null の場合、
          1. [85] 空文字列を返します。
        3. [86] それ以外の場合、
          1. [87] 状態の値で適合するものの正準形 (なければ空文字列) を返します。
      2. [30] それ以外の場合、
        1. [31] を返します。
      DOMString? (内容属性列挙属性)
      1. [88] 状態を、文脈オブジェクト内容属性状態に設定します。
      2. [89] 状態null の場合、
        1. [90] null を返します。
      3. [91] それ以外の場合、
        1. [92] 状態の値で適合するものの正準形を返します。
      boolean
      を返します。
      long
      1. [102] IDL属性limited to only non-negative numbersなら、
        1. [103] 結果を、rules for parsing non-negative integers を適用した結果に設定します。
      2. [104] それ以外の場合、
        1. [72] 結果を、rules for parsing signed integers を適用した結果に設定します。
      3. [82]
        • 結果失敗
        • 結果IDL属性の範囲外の値
        • 結果内容属性の範囲外の値
        ... のいずれかの場合、
        1. [94] 内容属性の既定値を返します。
      4. [95] それ以外なら、
        1. [101] 結果を返します。
      unsigned long
      1. [110] 結果を、rules for parsing non-negative integers を適用した結果に設定します。
      2. [111]
        ... のいずれかの場合、
        1. [112] 内容属性の既定値を返します。
      3. [36] それ以外の場合で、 IDL属性clamped to the rangeで、 IDL属性最小値 > の場合、
        1. [37] IDL属性最小値を返します。
      4. [38] それ以外の場合で、 IDL属性clamped to the rangeで、 IDL属性最大値 < の場合、
        1. [39] IDL属性最大値を返します。
      5. [113] それ以外の場合、
        1. [114] 結果を返します。
      doubleunrestricted double
      1. [123] 結果を、rules for parsing floating-point number values を適用した結果に設定します。
      2. [124]
        ... のいずれかの場合、
        1. [125] 内容属性の既定値を返します。
      3. [126] それ以外なら、
        1. [127] 結果を返します。

[70] IDL属性IDL属性内容属性内容属性設定器は、 次のようにしなければなりません >>6

  1. [81] を、指定された値をIDL属性変換した結果に設定します。
  2. [93] により、
    nullfalse
    文脈オブジェクト内容属性属性削除します。
    true
    文脈オブジェクト内容属性属性を、空文字列に設定します。
    USVString, DOMString
    文脈オブジェクト内容属性属性を、に設定します。
    long
    1. [106] IDL属性limited to only non-negative numbersなら、
      1. [107] なら、
        1. [108] IndexSizeError投げ、ここで停止します。
    2. [109] 文脈オブジェクト内容属性属性を、serialize an integer を適用した結果に設定します。
    unsigned long
    1. [118] 0 の場合、
      1. [120] IDL属性limited to only non-negative numbers greater than zeroなら、
        1. [119] IndexSizeError 例外投げ、ここで停止します。
      2. [121] それ以外で、IDL属性limited to only non-negative numbers greater than zero with fallbackなら、
        1. [122] を、内容属性の既定値に設定します。
    2. [115] それ以外で、が [ 0, 2147483647 ] の範囲外なら、
      1. [116] を、内容属性の既定値に設定します。
    3. [117] 文脈オブジェクト内容属性属性を、serialize an integer を適用した結果に設定します。
    doubleunrestricted double
    1. [129] 0 より大きくない場合、
      1. [130] IDL属性limited to numbers greater than zeroなら、
        1. [131] ここで停止します。
    2. [128] 文脈オブジェクト内容属性属性を、best representation of the number as a floating-point number に設定します。

[96] IDL属性? 以外の場合 (ほとんどの反映 IDL属性の場合) には、 null が指定されても変換時点で文字列化されてしまうので、 内容属性の削除には至りません。

[105] ここで、内容属性の既定値は、当該内容属性について特に規定がない場合、 limited to only non-negative numbers なら -1limited to only non-negative numbers greater than zero なら 1、 それ以外なら 0 です >>6

[147] なお、ここに示した処理の他に、 CEReactions の処理も行う必要があります。

[44] 2017年の改訂で、 crossOrigin IDL属性について limited to only known values であるとの記述が加わりました >>43。しかし IDL属性の型は DOMString? のままで変更されず、 DOMString? に関する limited to only known values の処理の規定はないため、 何を意味しているのかは不明です。ただ DOMString? は実際には crossOrigin のみで使われている規定なので、 実質的な規定の変更は無いものを思われます。

歴史

[3] 「reflect」という言葉を使って明示的にIDL属性内容属性の関係を明確に定義したのはおそらく HTML5 が最初です。それ以前の DOM1 HTMLDOM2 HTML では IDL属性の説明から HTML4 へリンクしていただけで、相互の関係を完全に明確には定義していませんでした。

[8] その後 DOM Standard も (文字列の) reflect を定義しました。

[9] SVGMathML にも reflect 相当の IDL属性がありますが、 DOM HTML スタイルの古い曖昧な説明になっていて、「reflect」とは言っていません。

[10] Atom DOM も「reflect」を定義しています。

[13] Remove HTMLAreaElement.hreflang and .type · Issue #232 · whatwg/html ( 版) <https://github.com/whatwg/html/issues/232>

[14] Fix #477: Unused spec content in common DOM interfaces · whatwg/html@06c2a32 ( 版) <https://github.com/whatwg/html/commit/06c2a3225194e61990f4930e7eb5887de28dd58a>

[15] Fix #358: use DOMTokenList exclusively · whatwg/html@98183f9 ( 版) <https://github.com/whatwg/html/commit/98183f98c609d61e508bbec46b7ab86d37b99b47>

[16] URLs are parsed and produce records · whatwg/html@30bc255 ( 版) <https://github.com/whatwg/html/commit/30bc2557105ad62881ec9670f253febbc9761b44>

[17] Adding [SameObject] to DOMTokenLists · whatwg/html@ec1dc4d ( 版) <https://github.com/whatwg/html/commit/ec1dc4d4571c61cf0c0dfe3e562898635886b412>

[19] Fix reflect and its callers · whatwg/dom@75303c5 ( 版) <https://github.com/whatwg/dom/commit/75303c5158db058fcd3bd21ac1ddc95bb2a18f9e>

[24] Fix #561: Reflecting a broken URL should return the unparsed value · whatwg/html@f9567cd ( 版) <https://github.com/whatwg/html/commit/f9567cd22f506d9a872cd6240555fb047fc75c67>

[25] Fix #859: Special-case empty string in reflect as URL · whatwg/html@f09dbee ( 版) <https://github.com/whatwg/html/commit/f09dbee68524c5ca8fd062a234e339d11c65e3b5>

[54] Fix #875: Editorial: Remove unused 'default value' in reflect as URL · whatwg/html@b2084ec ( 版) <https://github.com/whatwg/html/commit/b2084ec2f3818c0e8433dd5525b118b033b18294>

[55] Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7 ( 版) <https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd>

[56] Allow <menuitem> to have children giving the label · whatwg/html@8fdccb5 ( 版) <https://github.com/whatwg/html/commit/8fdccb55e40a36449ae6011f9960cb09c1da0db7>

[58] Reflect USVString IDL attributes for URLs as well as DOMString ones · whatwg/html@2ced624 ( 版) <https://github.com/whatwg/html/commit/2ced6248d16e5a742e324ba3f506cc6d179b0414>

[59] Hyperlink term "reflect" for <script>'s event and htmlFor · whatwg/html@9ab42dd ( 版) <https://github.com/whatwg/html/commit/9ab42dd45bcaa23523e5a196e5614449cf979d94>

[60] Formalize custom element reactions · whatwg/html@27aa7bc ( 版) <https://github.com/whatwg/html/commit/27aa7bc4fa6f168654a8c858f0773e611f679b39>

[61] Add [CEReactions] annotation to as · w3c/preload@b632000 ( 版) <https://github.com/w3c/preload/commit/b632000d8bd32118d3b7833b7c0caca044329072>

[62] Use USVString for all URLs ( (domenic著, )) <https://github.com/whatwg/html/commit/018b983b77b2cd908f6d00100e7e0abe893dd2c3>

[63] Scalable Vector Graphics (SVG) 2 ( ()) <https://svgwg.org/svg2-draft/single-page.html#types-TermReflect>

[64] Add the "as" attribute for the <link> element (sideshowbarker著, ) <https://github.com/whatwg/html/commit/2381476ea6143d835f08a3a82e6634b215cb60ea>

[67] Do not throw for zero colgroup/col.span and textarea.rows/cols (domenic著, ) <https://github.com/whatwg/html/commit/00b9b91548fbeb7a3c65bdaedf0a92d796183bcc>

[68] Revert "Fix #859: Special-case empty string in reflect as URL" (zcorpan著, ) <https://github.com/whatwg/html/commit/85227d27670d37382fe5e3dd2084a76cd4e9abf4>

[32] Remove old-fashioned vendor-specific extension advice (annevk著, ) <https://github.com/whatwg/html/commit/76f88a4015d55273749c34238d250b7bdb1aff62>

[34] Make <link>'s as="" attribute case-insensitive (domenic著, ) <https://github.com/whatwg/html/commit/9c7da4998f005c1799b04f452cb6c4a618f2d42e>

[35] Standardize special behavior of colspan/rowspan (ayg著, ) <https://github.com/whatwg/html/commit/4fbd00f5c5a839dcde33d2820c2cd57ddefa8a6e>

[40] Tweak <link>.workerType reflection (domenic著, ) <https://github.com/whatwg/html/commit/81032355f6c50131bda6d77c97299a273682c2e8>

[42] Remove <applet> (zcorpan著, ) <https://github.com/whatwg/html/commit/b9b9d60f9451c05f8e8d542e4094f987ae1a5fb8>

[43] Limit crossOrigin reflection to only known values (ayg著, ) <https://github.com/whatwg/html/commit/d967dc0120c137d0eb22808d4eaac0726cd8ea78>

[45] Editorial: no IDL attribute is said to reflect an HTMLElement anymore (annevk著, ) <https://github.com/whatwg/html/commit/f0f7a14c4eed844d6e099731e17dd993d626059a>

[46] Editorial: no IDL attribute is said to reflect an HTMLElement anymore by annevk · Pull Request #3055 · whatwg/html () <https://github.com/whatwg/html/pull/3055>