You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnfunction(){letmacrotask: MacroTask|undefined;// if this is a callback function, e.g, onSnapshot, we should create a microtask and invoke it// only once one of the callback functions is tripped.for(leti=0;i<arguments.length;i++){if(typeofarguments[i]==='function'){if(blockUntilFirst){macrotask||=run(()=>Zone.current.scheduleMacroTask('firebaseZoneBlock',noop,{},noop,noop));}// TODO create a microtask to track callback functionsarguments[i]=zoneWrapFn(arguments[i],macrotask);}}constret=runOutsideAngular(()=>(itasany).apply(this,arguments));// <--- `arguments` of the top function
In this source file, arguments is used as an array that contains the arguments of the function at the beginning. In fact, this code works fine in builds targeting ES2015 and later.
If you look at the zoneWrap part of the UNPKG file, you will see that the callback for the runOutsideAngular function is transpiled to a function, so the internal arguments changes the arguments it refers to.
returnfunction(){var_this_1=this;varmacrotask;// if this is a callback function, e.g, onSnapshot, we should create a microtask and invoke it// only once one of the callback functions is tripped.for(vari=0;i<arguments.length;i++){if(typeofarguments[i]==='function'){if(blockUntilFirst){macrotask||(macrotask=run(function(){returnZone.current.scheduleMacroTask('firebaseZoneBlock',noop,{},noop,noop);}));}// TODO create a microtask to track callback functionsarguments[i]=zoneWrapFn(arguments[i],macrotask);}}varret=runOutsideAngular(function(){returnit.apply(_this_1,arguments);});// <--- `arguments` of the nested function
How to fix
Upgrade ng-packagr to v13 and stop shiping UMD bundle (no ES5 transpliation)
Version info
Angular: v13
Firebase: 9.6
AngularFire: 7.2.0
Other (e.g. Ionic/Cordova, Node, browser, operating system):
How to reproduce these conditions
Actual behavior
angularfire/src/zones.ts
Lines 162 to 175 in b60670c
In this source file,
arguments
is used as an array that contains the arguments of the function at the beginning. In fact, this code works fine in builds targeting ES2015 and later.If you look at the zoneWrap part of the UNPKG file, you will see that the callback for the
runOutsideAngular
function is transpiled to afunction
, so the internalarguments
changes the arguments it refers to.https://unpkg.com/@angular/[email protected]/bundles/angular-fire.umd.js
How to fix
arguments
in callback functions (fix(core): avoid referring to arguments in arrow functions #3127)(...args) => {}
The text was updated successfully, but these errors were encountered: