Skip to content
Browse files

silence "layerX/Y" Webkit warnings for events

This means we can't just blindly extend all event properties onto the
event proxy object.
  • Loading branch information...
1 parent c49831f commit 18ba1f0b66c9bbd27909a0253b32314f598c6406 @mislav mislav committed Sep 28, 2012
Showing with 16 additions and 1 deletion.
  1. +5 −1 src/event.js
  2. +11 −0 test/event.html
View
6 src/event.js
@@ -103,13 +103,17 @@
var returnTrue = function(){return true},
returnFalse = function(){return false},
+ ignoreProperties = /^([A-Z]|layer[XY]$)/,
eventMethods = {
preventDefault: 'isDefaultPrevented',
stopImmediatePropagation: 'isImmediatePropagationStopped',
stopPropagation: 'isPropagationStopped'
}
function createProxy(event) {
- var proxy = $.extend({originalEvent: event}, event)
+ var key, proxy = { originalEvent: event }
+ for (key in event)
+ if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key]
+
$.each(eventMethods, function(name, predicate) {
proxy[name] = function(){
this[predicate] = returnTrue
View
11 test/event.html
@@ -129,6 +129,17 @@
this.el.off({ click: fn }).off({ click: fn2 }, null)
click(this.el)
t.assertEqual('a b c c', log.sort().join(' '))
+ },
+
+ testDelegateEventProperties: function(t){
+ var type, target
+ $(document).on('click', 'div', function(e){
+ type = e.type
+ target = e.target
+ })
+ click(this.el)
+ t.assertEqual('click', type)
+ t.assertIdentical(this.el.get(0), target)
}
})
})()

0 comments on commit 18ba1f0

Please sign in to comment.
Something went wrong with that request. Please try again.