mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
BeforeInputEventPlugin: Support Opera <= 12
Add support for Opera <= 12 (Presto) in `BeforeInputEventPlugin`. It turns out that Opera 12 has a `TextEvent` in `window`, but doesn't actually fire any input events. Even `input` apparently doesn't fire. Fall back to keypress handling in this case.
This commit is contained in:
1 parent
c40e06f728
commit
807e3dc423
1 file changed
+14
-1
@@ -29,9 +29,22 @@ var keyOf = require('keyOf');
|
||||
var canUseTextInputEvent = (
|
||||
ExecutionEnvironment.canUseDOM &&
|
||||
'TextEvent' in window &&
|
||||
!('documentMode' in document)
|
||||
!('documentMode' in document || isPresto())
|
||||
);
|
||||
|
||||
/**
|
||||
* Opera <= 12 includes TextEvent in window, but does not fire
|
||||
* text input events. Rely on keypress instead.
|
||||
*/
|
||||
function isPresto() {
|
||||
var opera = window.opera;
|
||||
return (
|
||||
typeof opera === 'object' &&
|
||||
typeof opera.version === 'function' &&
|
||||
parseInt(opera.version(), 10) <= 12
|
||||
);
|
||||
}
|
||||
|
||||
var SPACEBAR_CODE = 32;
|
||||
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
||||
|
||||
|
||||
Reference in new issue
Block a user