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

Polyfill doesn't work #7

Open
FluorescentHallucinogen opened this issue Aug 20, 2017 · 9 comments
Open

Polyfill doesn't work #7

FluorescentHallucinogen opened this issue Aug 20, 2017 · 9 comments

Comments

@FluorescentHallucinogen
Copy link
Contributor

Steps to reproduce:

  • Use a browser that doesn't support MediaStream Image Capture API.
  • Use the polyfill.

Expected results without using the polyfill:

'ImageCapture' in window // returns false

Expected results with using the polyfill:

'ImageCapture' in window // returns true

Actual results with using the polyfill:

'ImageCapture' in window // returns false
@FluorescentHallucinogen
Copy link
Contributor Author

@dandv PTAL.

@FluorescentHallucinogen
Copy link
Contributor Author

@beaufortfrancois
Copy link

@dandv I can reproduce on https://imagecapture.js.org/ with Safari. Can you have a look at why it fails?

@FluorescentHallucinogen
Copy link
Contributor Author

@KaptenJansson PTAL.

FluorescentHallucinogen added a commit to FluorescentHallucinogen/imagecapture-polyfill that referenced this issue Oct 29, 2017
@dandv
Copy link
Collaborator

dandv commented Jan 11, 2018

@beaufortfrancois and @FluorescentHallucinogen: I've merged some PRs to address Safari compatibility. Can you please test the latest build?

@FluorescentHallucinogen
Copy link
Contributor Author

FluorescentHallucinogen commented Jan 13, 2018

@dandv I opened this issue not because the polyfill didn't work in Safari, but because it didn't work in all (any) browsers that don't support Image Capture API natively (without enabling experimental flags), e.g. Firefox.

What was the problem?

If the browser support Image Capture API natively then it has ImageCapture in window, if the browser doesn't support Image Capture API natively then it has no ImageCapture in window.

What is this polyfill?

This polyfill is ES Module that compiled via Babel to UMD module and published to NPM.

How users install (use) this polyfill?

<script src="https://unpkg.com/image-capture@0.3.5/lib/imagecapture.js"></script>

What happens after that?

Since the browser don't support Image Capture API natively, it has no ImageCapture in window. We need add (overwrite) ImageCapture in window by our UMD module (automatically export it to window). But this didn't happen and polyfill doesn't work. :-(

I've fixed it 9b27bfd. But I'm not sure if this is the right way? Isn't this a hack? Maybe is there a more elegant way to export (add) ImageCapture to window e.g. by changing Babel UMD global config?

@FluorescentHallucinogen
Copy link
Contributor Author

BTW, please don't use https://imagecapture.js.org to reproduce this problem, because this demo is compiled by Webpack and don't use window.ImageCapture at all.

@FluorescentHallucinogen
Copy link
Contributor Author

@FluorescentHallucinogen
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants