lindell / lindell/JsBarcode

getRenderProperties doesn't recognize svg element

Open
#309 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

There is a bug in helper/getRenderProperties:
element && element.nodeName === 'svg'

This is caused by the fact browser can sometimes return nodeName UPPERCASE (see https://johnresig.com/blog/nodename-case-sensitivity/).

Therefore:
var element = document.createElementNS("http://www.w3.org/2000/svg", "svg"); JsBarcode(element, '123456789012', {format: "ean13"});
will work, but:
var element = document.createElement("svg"); JsBarcode(element, '123456789012', {format: "ean13"});
will throw an exception.

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

Read helper/getRenderProperties and compare its handling of the two SVG elements described in the issue. Verify that JsBarcode works with both document.createElementNS and document.createElement SVG elements without throwing an exception.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.