closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

goog.debug.ErrorHandler.prototype.protectWindowFunctionsHelper_ ignores variable-number arguments for timer functions

Open rcfox opened this issue 8 years ago • 4 comments

protectWindowFunctionsHelper_ is used to protect setTimeout, setInterval, but does not behave as a transparent wrapper. setTimeout and setInterval, are supposed to take a callback, timeout, as well as a variable number of arguments to be passed into the callback[1]. Only the first two arguments are taken by the wrapper function[2]. As a result, the additional arguments are undefined when the function is called.

It's possible to work around this issue by binding the arguments to the callback before passing it into the timer functions, but it's best to match the original signature to avoid unexpected behaviour from breaking code.

[1] http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#timers [2] https://github.com/google/closure-library/blob/master/closure/goog/debug/errorhandler.js#L279

rcfox avatar Oct 03 '15 00:10 rcfox

PR?

concavelenz avatar Oct 03 '15 05:10 concavelenz

Sorry, I'm not sure what you're asking.

rcfox avatar Oct 03 '15 09:10 rcfox

PR = Pull Request

joeltine avatar Oct 03 '15 17:10 joeltine

I don't have a pull request for you; I'm just reporting a bug.

rcfox avatar Oct 04 '15 02:10 rcfox