lindell / lindell/JsBarcode

Barcodes with lower case format (such as "codabara") are not initialized properly by init() from HTML code

Open
#336 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.