Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Enable IE 11 compability of Angular + pdf.js #15772

Closed
nemoinho opened this issue Mar 3, 2017 · 6 comments
Closed

Enable IE 11 compability of Angular + pdf.js #15772

nemoinho opened this issue Mar 3, 2017 · 6 comments

Comments

@nemoinho
Copy link

nemoinho commented Mar 3, 2017

Do you want to request a feature or report a bug?
feature

What is the current behavior?
Currently pdf.js defines document.currentScript but not link.origin nor link.protocol. If angular starts it checks if it is allowed to bootstrap automatically it checks for currentScript and asume that this will be enough to filter IE. This check will not work in combination with pdf.js

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
To demonstrate this behaviour there is a plnkr with a minimal environment, that shows the problem: http://plnkr.co/edit/YFCQM2Px0QU0KnGzsAlM?p=preview

What is the expected behavior?
Angular should check also for link.origin and link.protocol if they are implemented, to make sure that it works correctly with e.g. pdf.js

What is the motivation / use case for changing the behavior?
pdf.js is widely used to render pdfs and angular is spreaded for web-apps. They will occur on the same page more often than probably expected, because they work in similiar domains, so they shouldn't interfier each other.

Which versions of AngularJS, and which browser / OS are affected by this issue? Did this work in previous versions of AngularJS? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
The whole angular 1.6.x tree is affected. The problem only occurs on IE 11 on each Windows.

Other information (e.g. stacktraces, related issues, suggestions how to fix)
Probably there can be a additional check for link.origin like:

if (link.origin !== undefined && document.location.origin === link.origin) { …

And there can be a case for the undefined protocol:

switch (link.protocol) {
  case 'http:':
  case 'https:':
  case 'ftp:':
  case 'blob:':
  case 'file:':
  case 'data:':
  case undefined:
    return true;
  default:
    return false;
}
@Narretz
Copy link
Contributor

Narretz commented Mar 3, 2017

Can you post a demo where the actual pdf.js and AngularJS files are used? I cannot reproduce the issue. To clarify, what you mean is that AngularJS autoboostrap is not working in IE11 when pdf.js is included?

@petebacondarwin
Copy link
Member

The workaround for this is simple. If you are using PDF.js on IE then you just manually bootstrap AngularJS. So instead of relying upon <body ng-app="app"> you use:

angular.bootstrap(document.body, ['app']);

It is unlikely that we will fix this on our side. It is PDF.js that is polyfilling document without accounting for what other libraries might be expecting.

@mgol
Copy link
Member

mgol commented Mar 3, 2017

I'd add that libraries shouldn't modify properties of objects they don't own as it causes issues like that (& many others). If they need a particular API that is missing in some supported environments they may wrap its usage in a function that will use the shimmed version if the native one is not available.

@nemoinho
Copy link
Author

nemoinho commented Mar 7, 2017

Thanks for the discussion the argument are valid and good. So I'll close this issue.

@nemoinho nemoinho closed this as completed Mar 7, 2017
@petebacondarwin
Copy link
Member

Thanks for closing.

@icevic1
Copy link

icevic1 commented Dec 5, 2017

Faced with this issue on Firefox and angular 1.6.x
anybody solve it? how?

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

No branches or pull requests

5 participants