ElemeFE / ElemeFE/image-cropper-touch

With Android 6.0, got a typeError "Failed to execute 'toBlob'"

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13
Forks
6
PR merge metrics
No merged PRs in 30d

Description

### Error:
```
Uncaught TypeError: Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only 0 present.
```
**Device: Nexus 6**
**Android version: 6.0.1**
### My Opinion:
I think it is because this line:
```
file: canvas.toBlob ? canvas.toBlob() : dataURItoBlob(dataURL),
```
On Android 6.0, `canvas.toBlob ` is to be `true`, so the `file` equal to `canvas.toBlob()`.

Based on [MDN](https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLCanvasElement/toBlob)
```
void canvas.toBlob(callback, type, encoderOptions);
```
`toBlob` must has 1 argument at least. But your code doesn't has 1 argument.

**Can you please fix it ? Thank you.**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.