Re: [whatwg] set input.value when input element has composition string

2011-03-03 Thread Makoto Kato

Hi, Niwa-san.

On 2011/03/02 15:30, Ryosuke Niwa wrote:
On Tue, Mar 1, 2011 at 5:18 PM, Makoto Kato <mailto:m_k...@ga2.so-net.ne.jp>> wrote:


On Safari 5, even if textbox has IME composition string, text into
textbox can be replaced by DOM/script.  But other browser's
behaviors are different, and this is no specification when textbox
has composition string.  Although IE, Chrome and Opera keep
composition string after value is replaced by DOM, each behavior
is different.

This is the result for this test on each browsers.  When textbox
has IME composition string such as ABCDEFG, then script
(textbox.value = "123";) is called, textbox becomes...

1. "123ABCDEFG" (ABCDEFG keeps composition state and caret is
after G).
2. "123" (composition string is removed).
3. "ABCDEFG" (ABCDEFG keeps composition state and caret is after G).

Which behavior is right?  1 is Opera 11, 2 is Safari 5, and 3 is
Chrome 10 and IE9.


You must have tested Chrome improperly.  We currently have a bug in 
Chrome.  To see the bug, open the attached test and type "nihao" with 
Chinese IME on Windows or Mac.  Then press down array key.  The text 
is replaced by henhao but "henha" is still marked and looks as if I'm 
compositing "henha" but if I continue to type "ma" still with IME, 
then I observe that "henhaomao" is shown inside the input element. 
 Once this bug is fixed, Chrome's behavior should match that of Safari 5.


Do you think Safari's way (ex. 2) is right?   I found some bugs on 
Chrome (and IE and Opera) when I test this, but I am not interesting 
about bugs.


It is confused that each Web browser is different behavior for this . 
This is not good as interoperability. So I would like to decide the 
right behavior/specification when textbox.value = 'x'; that it has 
composition string.


Also, some people says that it should not be canceled/removed even if 
value is changed by DOM.  Because composition string is un-committed string.


Niwa-san and folks, how do you think right design for this situation??


-- Makoto Kato



Re: set input.value when input element has composition string

2011-03-01 Thread Makoto Kato

Hi, Kang-Hao.

On 2011/02/28 21:31, Kang-Hao (Kenny) Lu wrote:

Hello Makoto,
(Cc+ public-webapps)

(11/02/25 15:16), Makoto Kato wrote:

Hi,

This is simple sample.  This behavior is different on all web browsers
when input element has composition/preedit string for IME.

A relevant question here, I think, is where the cursor should go when
the value of the text box is set by script. For Safari5, it always goes
to the end when the value is set. For FF4.0b11, the cursor stays in
previous position when the value to be set is the same and goes to the
end when the value is different. Is this a known incompatibility? I find
the behavior of FF quite strange.


On Safari 5, even if textbox has IME composition string, text into 
textbox can be replaced by DOM/script.  But other browser's behaviors 
are different, and this is no specification when textbox has composition 
string.  Although IE, Chrome and Opera keep composition string after 
value is replaced by DOM, each behavior is different.


This is the result for this test on each browsers.  When textbox has IME 
composition string such as ABCDEFG, then script (textbox.value = "123";) 
is called, textbox becomes...


1. "123ABCDEFG" (ABCDEFG keeps composition state and caret is after G).
2. "123" (composition string is removed).
3. "ABCDEFG" (ABCDEFG keeps composition state and caret is after G).

Which behavior is right?  1 is Opera 11, 2 is Safari 5, and 3 is Chrome 
10 and IE9.


Also, on Firefox/Gecko, since there is some bugs, key input cannot work 
until IME is turned off.  So to fix this, I am talking with Ehsan about 
right specification.  But there is no discussion about this 
specification/behavior at WHATWG.



If input element has composition string by IME, should it cancel
composition string and set value by script?  Or should it cancel
setting value since it has composition string?

What makes sense to me is:
1. the cursor always goes to the end
2. the composition string goes with the cursor, which should not change.

But I am not sure whether this is the right way to go.

Cheers,
Kenny



function setvalue() {
   document.getElementById('test').value = "replaced";
}






-- Makoto Kato


-- Makoto Kato