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

"'Promise' is undefined" in IE11 #257

Closed
bengtmoss opened this issue Jan 27, 2017 · 6 comments
Closed

"'Promise' is undefined" in IE11 #257

bengtmoss opened this issue Jan 27, 2017 · 6 comments

Comments

@bengtmoss
Copy link

bengtmoss commented Jan 27, 2017

I'm testing the pnp.js of the latest PnP-JS-Core, using an Install and Use example

The example includes the use of promise. The instructions say that this will fail in IE11 unless I add the es6-promise polyfill and the fetch polyfill and include them in the example.

So I did, but in IE11, when invoking the invocation of "then":

$pnp.sp.web.select("Title").get()
.then(function (data) {
    document.getElementById("main").innerText = 'Web title: ' + data.Title;
})
.catch(function (ex) {
    document.getElementById("main").innerText = 'Exception: ' + ex;
});

still fails with the exception: "'Promise' is undefined".

Any suggestions why that might be?

@cvorwerk
Copy link

I have the same problem with IE11. The same code runs correct in Firefox. I swich featch/es6 loading and test minimal versions. :/

@ray007
Copy link

ray007 commented Feb 20, 2017

I'd blame the fetch polyfill. Using the promise polyfill here also with IE 10/11 and no problems.

@azizhk
Copy link
Contributor

azizhk commented Mar 2, 2017

Hi, I think you need to use the auto file for automatic polyfilling.
The other file just exports the Promise method (window.ES6Promise) but does not set window.Promise variable.

This is done because when you have multiple dependencies each having their own version/spec of Promise implementation where you don't want to pollute the global environment with one particular version. So this is left to the developer to choose what variable he wishes to define as what Promise spec.

@daryllabar
Copy link

I'm getting an error in IE 11: Expected identifier (1075,21) IE 11 has a bug in it's JS engine (at least on my machine it does) where catch is not interpreted as a function name, but as a try{}catch(){} and is failing...

	Promise.prototype.catch = function _catch(onRejection) {
		return this.then(null, onRejection);
	};

If I fix that error, I also get the same error on the finally.

Maybe this is due to compatibility mode?
Am I doing something wrong?

@daryllabar
Copy link

I'm getting an error in IE 11: Expected identifier (1075,21) IE 11 has a bug in it's JS engine (at least on my machine it does) where catch is not interpreted as a function name, but as a try{}catch(){} and is failing...

	Promise.prototype.catch = function _catch(onRejection) {
		return this.then(null, onRejection);
	};

If I fix that error, I also get the same error on the finally.

Maybe this is due to compatibility mode?
Am I doing something wrong?

Looks like this was an IE Compatibility issue. The minified or the es6-promises actually does have the ["catch"] and ["finally"] values defined correctly.

@ray007
Copy link

ray007 commented Oct 24, 2018

Seems I maybe do not have the latest version here, "catch" needs to be a quoted property:
Promise.prototype['catch'] = ...

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

6 participants