mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Add support for HTML input event (aka oninput) on text fields.
The input event is like onchange, but on text fields, it is fired as soon as the value of the field changes, not when the field is blurred. It is a more appropriate event than 'keydown' or 'keyup', which behave unpredictably with paste events, held-down keys, etc. Support is a little problematic, but it is supported well by Webkit and Firefox, so it seems useful to add here.
This commit is contained in:
parent
fc56a13a6b
commit
fc5cba3ee0
2 changed files with 3 additions and 1 deletions
|
@ -659,6 +659,7 @@ describe Capybara::Driver::Webkit do
|
||||||
element.addEventListener("keydown", recordEvent);
|
element.addEventListener("keydown", recordEvent);
|
||||||
element.addEventListener("keypress", recordEvent);
|
element.addEventListener("keypress", recordEvent);
|
||||||
element.addEventListener("keyup", recordEvent);
|
element.addEventListener("keyup", recordEvent);
|
||||||
|
element.addEventListener("input", recordEvent);
|
||||||
element.addEventListener("change", recordEvent);
|
element.addEventListener("change", recordEvent);
|
||||||
element.addEventListener("blur", recordEvent);
|
element.addEventListener("blur", recordEvent);
|
||||||
element.addEventListener("mousedown", recordEvent);
|
element.addEventListener("mousedown", recordEvent);
|
||||||
|
@ -678,7 +679,7 @@ describe Capybara::Driver::Webkit do
|
||||||
|
|
||||||
let(:keyevents) do
|
let(:keyevents) do
|
||||||
(%w{focus} +
|
(%w{focus} +
|
||||||
newtext.length.times.collect { %w{keydown keypress keyup} } +
|
newtext.length.times.collect { %w{keydown keypress keyup input} } +
|
||||||
%w{change blur}).flatten
|
%w{change blur}).flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,7 @@ Capybara = {
|
||||||
this.trigger(index, "keydown");
|
this.trigger(index, "keydown");
|
||||||
this.keypress(index, false, false, false, false, 0, value.charCodeAt(strindex));
|
this.keypress(index, false, false, false, false, 0, value.charCodeAt(strindex));
|
||||||
this.trigger(index, "keyup");
|
this.trigger(index, "keyup");
|
||||||
|
this.trigger(index, "input");
|
||||||
}
|
}
|
||||||
this.trigger(index, "change");
|
this.trigger(index, "change");
|
||||||
this.trigger(index, "blur");
|
this.trigger(index, "blur");
|
||||||
|
|
Loading…
Reference in a new issue