The library for web and native user interfaces.
Revert `Object.create` in NormalizedEventListener
It seems that the use of Object.create (to comply with strict mode) in NormalizedEventListener is not happy in IE8.
CommitSyncScript committed
Jun 4, 2013 at 12:16 UTC
606d6b8fd4dfc88c16f56e8787ace37bf140440f
1 file changed
+7
-11
src/event/NormalizedEventListener.js
+7
-11
@@ -16,8 +16,6 @@
16
* @providesModule NormalizedEventListener
17
*/
18
19
-"use strict";
20
-
19
var EventListener = require('EventListener');
20
21
/**
@@ -26,25 +24,23 @@ var EventListener = require('EventListener');
24
* @private
25
*/
26
function normalizeEvent(eventParam) {
29
- var normalized = eventParam || window.event;
27
+ var nativeEvent = eventParam || window.event;
28
// In some browsers (OLD FF), setting the target throws an error. A good way
29
// to tell if setting the target will throw an error, is to check if the event
30
// has a `target` property. Safari events have a `target` but it's not always
31
// normalized. Even if a `target` property exists, it's good to only set the
32
// target property if we realize that a change will actually take place.
35
- var hasTargetProperty = 'target' in normalized;
36
- var eventTarget = normalized.target || normalized.srcElement || window;
33
+ var hasTargetProperty = 'target' in nativeEvent;
34
+ var eventTarget = nativeEvent.target || nativeEvent.srcElement || window;
35
// Safari may fire events on text nodes (Node.TEXT_NODE is 3)
36
// @see http://www.quirksmode.org/js/events_properties.html
37
var textNodeNormalizedTarget =
38
(eventTarget.nodeType === 3) ? eventTarget.parentNode : eventTarget;
41
- if (!hasTargetProperty || normalized.target !== textNodeNormalizedTarget) {
42
- // Create an object that inherits from the native event so that we can set
43
- // `target` on it. (It is read-only and setting it throws in strict mode).
44
- normalized = Object.create(normalized);
45
- normalized.target = textNodeNormalizedTarget;
39
+ if (!hasTargetProperty || nativeEvent.target !== textNodeNormalizedTarget) {
40
+ // TODO: Normalize the object via `merge()` to work with strict mode.
41
+ nativeEvent.target = textNodeNormalizedTarget;
42
}
47
- return normalized;
43
+ return nativeEvent;
44
}
45
46
function createNormalizedCallback(cb) {