Skip to content

Commit

Permalink
Fix V8 warning 'Not Optimized: Bad value context for arguments value'
Browse files Browse the repository at this point in the history
  • Loading branch information
satori-avasenin committed May 29, 2017
1 parent 24c3e9d commit 0ae2291
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,25 @@ Observer.prototype = {
* [Subscription]{@link Subscription} object.
*
* @param {string} name - Event name.
* @param {...Object} args - Event arguments.
*
* @return {void}
*/
fire: function (name) {
var col = this.handlers[name] || [];
var args = Array.prototype.slice.call(arguments);
args.shift();
col.forEach(function (fn) {
fire: function () {
var name;
var fns;
var i;
var len = arguments.length;
// Copy arguments to solve 'Not optimized: Bad value context for arguments value'
// See https://github.com/GoogleChrome/devtools-docs/issues/53#issuecomment-51941358
var args = new Array(len);
for (i = 0; i < len; i += 1) {
args[i] = arguments[i];
}
name = args.shift();

fns = this.handlers[name] || [];
fns.forEach(function (fn) {
try {
fn.apply(null, args);
} catch (e) {
Expand Down

0 comments on commit 0ae2291

Please sign in to comment.