| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 { | 73 { |
| 74 this.off(name, listener); | 74 this.off(name, listener); |
| 75 resolve(); | 75 resolve(); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 this.on(name, listener); | 78 this.on(name, listener); |
| 79 }); | 79 }); |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Returns a copy of the array of listeners for the specified event. |
| 84 * |
| 85 * @return {function[]} |
| 86 */ |
| 87 listeners: function(name) |
| 88 { |
| 89 let listeners = this._listeners[name]; |
| 90 return listeners ? listeners.slice() : []; |
| 91 }, |
| 92 |
| 93 /** |
| 83 * Calls all previously added listeners for the given event name. | 94 * Calls all previously added listeners for the given event name. |
| 84 * | 95 * |
| 85 * @param {string} name | 96 * @param {string} name |
| 86 * @param {...*} [arg] | 97 * @param {...*} [arg] |
| 87 */ | 98 */ |
| 88 emit: function(name) | 99 emit: function(name) |
| 89 { | 100 { |
| 90 let listeners = this._listeners[name]; | 101 let args = []; |
| 91 if (listeners) | 102 for (let i = 1; i < arguments.length; i++) |
| 92 { | 103 args.push(arguments[i]); |
| 93 let args = []; | |
| 94 for (let i = 1; i < arguments.length; i++) | |
| 95 args.push(arguments[i]); | |
| 96 | 104 |
| 97 let currentListeners = listeners.slice(); | 105 let listeners = this.listeners(name); |
| 98 for (let listener of currentListeners) | 106 for (let listener of listeners) |
| 99 listener.apply(null, args); | 107 listener.apply(null, args); |
| 100 } | |
| 101 } | 108 } |
| 102 }; | 109 }; |
| OLD | NEW |