Commit 884e1b60 884e1b6076178a07c0c1280b63744bd161103dad by nrabinowitz

Fixing mouse.processEvent method

1 parent 7bf96e3f
...@@ -39,6 +39,8 @@ var Mouse = function(casper) { ...@@ -39,6 +39,8 @@ var Mouse = function(casper) {
39 throw new CasperError('Mouse() needs a Casper instance'); 39 throw new CasperError('Mouse() needs a Casper instance');
40 } 40 }
41 41
42 var slice = Array.prototype.slice;
43
42 var supportedEvents = ['mouseup', 'mousedown', 'click', 'mousemove']; 44 var supportedEvents = ['mouseup', 'mousedown', 'click', 'mousemove'];
43 45
44 function computeCenter(selector) { 46 function computeCenter(selector) {
...@@ -54,7 +56,7 @@ var Mouse = function(casper) { ...@@ -54,7 +56,7 @@ var Mouse = function(casper) {
54 if (!utils.isString(type) || supportedEvents.indexOf(type) === -1) { 56 if (!utils.isString(type) || supportedEvents.indexOf(type) === -1) {
55 throw new CasperError('Mouse.processEvent(): Unsupported mouse event type: ' + type); 57 throw new CasperError('Mouse.processEvent(): Unsupported mouse event type: ' + type);
56 } 58 }
57 args = Array.prototype.slice.call(args); // cast Arguments -> Array 59 args = slice.call(args); // cast Arguments -> Array
58 casper.emit('mouse.' + type.replace('mouse', ''), args); 60 casper.emit('mouse.' + type.replace('mouse', ''), args);
59 switch (args.length) { 61 switch (args.length) {
60 case 0: 62 case 0:
...@@ -79,7 +81,9 @@ var Mouse = function(casper) { ...@@ -79,7 +81,9 @@ var Mouse = function(casper) {
79 } 81 }
80 } 82 }
81 83
82 this.processEvent = processEvent; 84 this.processEvent = function() {
85 processEvent(arguments[0], slice.call(arguments, 1));
86 }
83 87
84 this.click = function click() { 88 this.click = function click() {
85 processEvent('click', arguments); 89 processEvent('click', arguments);
......