Barcodes with lower case format (such as "codabara") are not initialized properly by init() from HTML code
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
The following HTML code does not render a barcode in format "codabar" but results in the following error:
JsBarcode.all.js:1509 Uncaught TypeError: Encoder is not a constructor
at encode (JsBarcode.all.js:1509)
at JsBarcode.all.js:1583
at ErrorHandler.wrapBarcodeCall (JsBarcode.all.js:1194)
at API.init (JsBarcode.all.js:1579)
at index.html:7
> < script src="JsBarcode.all.js" >
> < svg id="barcode" jsbarcode-format="codabar" jsbarcode-value="A01234567890A" jsbarcode-height="100">
> < script>JsBarcode("#barcode").init();
I found the following line
`var Encoder = _barcodes2.default[options.format.toUpperCase()];`
and was able to fix the issue by replacing it with
`var Encoder = _barcodes2.default[options.format.toUpperCase()] || _barcodes2.default[options.format.toLowerCase()];`
I'm not sure if this is the right place to fix the bug, but it seems to be a general problem with barcode formats in lower case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the HTML example in index.html and trace API.init through JsBarcode.all.js, especially the encode call around line 1509. Verify that the lower-case codabar format renders successfully and that other lower-case barcode formats no longer raise the reported constructor error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100