selectionStart/End未対応はバグか仕様か

 saitonさんのダイアリーid:saiton:20050129:1106977884」の続報部分を拝見しました。
 saitonさんがOperaメーリングリストのwishlistにこの件を投稿してくださったところ、selectionStart/EndはOpera8で対応されるかもしれないとのコメントが付いたようです。(Opera社の公式発言ではないので、期待しすぎるのも禁物みたいです)
 saitonさん、ありがとうございます、m(_ _)m


 そこで紹介していただいているoperaメーリングリストのアーカイブも拝見しました。
 その一つによると、W3C DOM Level 2では、textareaの内容を操作することは禁止されているとのことです。
 ちょっと長いですが、引用します。

That is why the W3C DOM Level 2 HTML specification clearly says about the value property:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-70715579
"Represents the current contents of the corresponding form control, in an interactive user agent. Changing this attribute changes the contents of the form control, but does not change the contents of the element."
and about the defaultValue property:
"Represents the contents of the element. The value of this attribute does not change if the contents of the corresponding form control, in an interactive user agent, changes."

Thus when the user types into a textarea the initial content of the <textarea> element doesn't change, only the visual content of the corresponding <textarea> control changes and in the DOM that change is reflected by the property named value.

とのことです。何が書いてあるんでしょうね? 私、フランス語は苦手で。(笑)
 sasada的には「テキストエリアって、『contents of the form control』じゃないのかなぁ」とか思っていたので、「テキストエリアのdefaultValueプロパティは変更不能だけど、valueプロパティは変更可能だよ」って思ってたのですが、よく調べると、テキストエリアはformの内容扱いじゃぁ無かったんですね。ショック!!
 どうやら、「テキストエリアはformの内容扱いじゃ無い(要素扱いとなる)から、valueを変更しちゃダメだよ」というのが、正しい【仕様】のようです。
 ・・・そ、そんなぁーーー。


 でも、仕様の意味する『contents of the form control』に、「form要素の子供要素としてのテキストエリア」が含まれるなら、やっぱりvalueは変更可能なわけで、実際にはよく分かんないです。(^^;


 それはそれとして、WHATWG (Web Hypertext Application Technology Working Group) と言うところの要望集に、

  • Rich text editing: an underlying architecture upon which domain-specific editors can be created, including things like control over the caret position.
  • A predefined HTML editor based on the rich text editing architecture.
  • Text selection manipulation APIs.

が挙がってますし、Opera8で導入される可能性はあると思います。
 ちなみに、Opera8は 2月末リリース予定かもです。(英語版)