lindell / JsBarcode

Barcode generation library written in JavaScript that works in both the browser and on Node.js
http://lindell.me/JsBarcode
MIT License
5.45k stars 1.1k forks source link

Uncaught TypeError When Reading Undefined Text #391

Open aaronsheldon opened 2 years ago

aaronsheldon commented 2 years ago

As of version 3.5.9, the following line generates an uncaught type error when attempting to read the undefined text: https://github.com/lindell/JsBarcode/blob/master/dist/JsBarcode.all.js#L190 The following minimal example from CodePen will work with 3.5.8 but not on or after 3.5.9:

const api = JsBarcode("#barcode");
api["CODE128"]("Hello");
api.blank(20);
api["CODE128"]("World");
api.render();

In contrast explicitly passing the text does render:

const api = JsBarcode("#barcode");
api["CODE128"]("Hello", { text: "Hello" });
api.blank(20);
api["CODE128"]("World", { text: "World" });
api.render();
lindell commented 2 years ago

Thanks for an excellent bug report! I will take look at this as soon as I have the time.