Limit base-class initialization checks to development and TESTING modes

We have a number of base-classes that are only intended to be extended, but never to be used directly. To help enforce this during development these base-class constructors will check for direct usage, however that code is obviously not needed in the actual builds.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `~2.7` kilo-bytes, which isn't a lot but still cannot hurt.
This commit is contained in:
Jonas Jenwald 2024-08-12 11:59:13 +02:00
parent aa2337f934
commit aebb8534f3
16 changed files with 79 additions and 20 deletions

View file

@ -98,7 +98,10 @@ class BaseShading {
static SMALL_NUMBER = 1e-6;
constructor() {
if (this.constructor === BaseShading) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
this.constructor === BaseShading
) {
unreachable("Cannot initialize BaseShading.");
}
}