]> git.ipfire.org Git - thirdparty/Chart.js.git/commit
[fix] Handle non-primitives in isNumber (#12034)
authorJosh Kelley <joshkel@gmail.com>
Sun, 16 Feb 2025 17:24:26 +0000 (12:24 -0500)
committerGitHub <noreply@github.com>
Sun, 16 Feb 2025 17:24:26 +0000 (12:24 -0500)
commit2f425290ee077d9d013af77fa978d6b6d6885634
treefa0e1ac3a353358f2d425ac63f74df3804e0452c
parent370f6c385d648ab52f576824b9a22453fa4648f1
[fix] Handle non-primitives in isNumber (#12034)

While investigating https://github.com/chartjs/chartjs-plugin-zoom/issues/928, I found that `isNonPrimitive` will throw TypeError on a Moment.js object after it's passed through Chart.js's options proxy, because the object has its `Symbol.toPrimitive`, `toString`, and `valueOf` all set to null.

(See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion for background reading.)

Since isNumber appears to be a low-level function that can take any arbitrary input, it seems worth letting it handle this case.
src/helpers/helpers.math.ts
test/specs/helpers.math.tests.js