Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lib): throttle ignored force argument #6438

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

chitoku-k
Copy link

@chitoku-k chitoku-k commented Jun 8, 2024

Fixes #6417

On line 14 of lib/helpers/throttle.js, throttle expects this to be true when a call to fn is enforced; however, this would never equal to true / false in non-strict mode as this cannot be a primitive. It instead is a wrapper object around the value in non-strict mode when it is called by Function.prototype.call() with this bound to any primitive value.

This PR partially reverts d01386e by making force a parameter so it works both in strict and non-strict mode.

f = function () {
  console.log(this === true);
  console.log(this instanceof Boolean);
  console.log(this.valueOf() === true);
};

f.call(true) // => false true true
g = function () {
  'use strict';
  console.log(this === true);
  console.log(this instanceof Boolean);
  console.log(this.valueOf() === true);
};

g.call(true) // => true false true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onDownloadProgress changed after 1.6.8
1 participant