Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.3.1 #588

Merged
merged 10 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Version 2.3.1
- Improved support for UPC types - by [Breno1288](https://github.com/Breno1288), forked from PR - [pull#501](https://github.com/mebjas/html5-qrcode/pull/501)
- Fix form submission in Firefox issue - [Discussion#413](https://github.com/mebjas/html5-qrcode/discussions/413#discussioncomment-2124480) by [Joggel72](https://github.com/Joggel72), forked from PR - [pull#431](https://github.com/mebjas/html5-qrcode/pull/431)
- Fix support for UPC-E as called out in several bugs - [parent issue#605](https://github.com/mebjas/html5-qrcode/issues/605)
- Add `willReadFrequently` attribute to canvas context for camera scan as per Google Chrome recommendation.

### Version 2.3.0

- Added support for drag and drop of image in file based scanner.
Expand Down
3 changes: 1 addition & 2 deletions minified/html5-qrcode.min.js

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/html5-qrcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,11 +1174,17 @@ export class Html5Qrcode {

const canvasElement = this.createCanvasElement(
qrRegion.width, qrRegion.height);
// Tell user agent that this canvas will be read frequently.
// More info:
// https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
const contextAttributes: any = { willReadFrequently: true };
// Casting canvas to any, as Microsoft's interface definition hasn't
// caught up with latest definition for 'CanvasRenderingContext2DSettings'.
const context: CanvasRenderingContext2D
= canvasElement.getContext("2d")!;
= (<any>canvasElement).getContext("2d", contextAttributes)!;
context.canvas.width = qrRegion.width;
context.canvas.height = qrRegion.height;

// Insert the canvas
this.element!.append(canvasElement);
if (shouldShadingBeApplied) {
Expand Down
3 changes: 3 additions & 0 deletions src/ui/scanner/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export class BaseUiElementFactory {
let element: Type = <Type>(document.createElement(elementType));
element.id = elementId;
element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS);
if (elementType === "button") {
element.setAttribute("type", "button");
}
return element;
}
}
2 changes: 2 additions & 0 deletions src/zxing-html5-qrcode-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync {
const formats = this.createZXingFormats(requestedFormats);
const hints = new Map();
hints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, formats);
// TODO(minhazav): Make this configurable by developers.
hints.set(ZXing.DecodeHintType.TRY_HARDER, false);
this.hints = hints;
}

Expand Down
20 changes: 18 additions & 2 deletions tests/ui/scanner/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,32 @@ describe("BaseUiElementFactory#createElement()", () => {
it("Creates element with expected ID", () => {
const expectedId = "test-id";
let button = BaseUiElementFactory.createElement<HTMLButtonElement>(
"select", expectedId);
"button", expectedId);
expect(button.id).eq(expectedId);
});

it("Creates element with common class", () => {
let button = BaseUiElementFactory.createElement<HTMLButtonElement>(
"select", "test-id");
"button", "test-id");
let hasClass = button.classList.contains(
PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS);

expect(hasClass).to.be.true;
});

it("Creates button element with button type attribute", () => {
let button = BaseUiElementFactory.createElement<HTMLButtonElement>(
"button", "test-id");
let typeAttributeValue = button.getAttribute("type");

expect(typeAttributeValue).eq("button");
});

it("Creates select element without type attribute", () => {
let select = BaseUiElementFactory.createElement<HTMLSelectElement>(
"select", "test-id");
let typeAttributeValue = select.getAttribute("type");

expect(typeAttributeValue).to.be.null;
});
});
3 changes: 2 additions & 1 deletion third_party/zxing-js.umd.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ declare class MultiFormatReader {
}

export declare enum DecodeHintType {
POSSIBLE_FORMATS = 2
POSSIBLE_FORMATS = 2,
TRY_HARDER = 3
}

export declare enum BarcodeFormat {
Expand Down
Loading