Skip to content

Commit 807e3dc

Browse files
Isaac Salier-Hellendagzpao
authored andcommitted
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.
1 parent c40e06f commit 807e3dc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/browser/eventPlugins/BeforeInputEventPlugin.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,22 @@ var keyOf = require('keyOf');
2929
var canUseTextInputEvent = (
3030
ExecutionEnvironment.canUseDOM &&
3131
'TextEvent' in window &&
32-
!('documentMode' in document)
32+
!('documentMode' in document || isPresto())
3333
);
3434

35+
/**
36+
* Opera <= 12 includes TextEvent in window, but does not fire
37+
* text input events. Rely on keypress instead.
38+
*/
39+
function isPresto() {
40+
var opera = window.opera;
41+
return (
42+
typeof opera === 'object' &&
43+
typeof opera.version === 'function' &&
44+
parseInt(opera.version(), 10) <= 12
45+
);
46+
}
47+
3548
var SPACEBAR_CODE = 32;
3649
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
3750

0 commit comments

Comments
 (0)