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.
Isaac Salier-Hellendag committed
Mar 28, 2014 at 11:55 UTC
807e3dc42375fbc15c41c847a38acfd518fba7a1
1 file changed
+14
-1
src/browser/eventPlugins/BeforeInputEventPlugin.js
+14
-1
@@ -29,9 +29,22 @@ var keyOf = require('keyOf');
29
var canUseTextInputEvent = (
30
ExecutionEnvironment.canUseDOM &&
31
'TextEvent' in window &&
32
- !('documentMode' in document)
32
+ !('documentMode' in document || isPresto())
33
);
34
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
+
48
var SPACEBAR_CODE = 32;
49
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
50