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

AngularJs (all versions) breaks on IE11 in document mode ie=8 #4137

Closed
derbernd86 opened this issue Sep 24, 2013 · 24 comments
Closed

AngularJs (all versions) breaks on IE11 in document mode ie=8 #4137

derbernd86 opened this issue Sep 24, 2013 · 24 comments

Comments

@derbernd86
Copy link

Hello,
due to restrictions with legacy applications, my angularjs app is loaded in an iframe. The surrounding website has the document mode ie=8. <meta http-equiv="X-UA-Compatible" content="IE=8" />

So every website that is loaded within the iframe is also rendered in the ie8 documentmode.

Unfortunately Angular Js doesn't work in Internet Explorer 11 with the document mode ie=8 as described above.

I made a very simple example (see below) where this problem also occurs. It's based on an example of angularjs.org.

If you change the document mode e. g. to <meta http-equiv="X-UA-Compatible" content="IE=9" /> the example works.

This problem seams to appear in all angularjs versions. I tried 1.0.3, 1.0.8, 1.1.5 and 1.2.0-rc.2.

I hope you can help me.

Best regards
Bernd Hartmann

Sorry for the code here, but I didn't get the document mode run in an jsfiddle or Plunker.

1.) ie11testappframe.html

<!doctype html>
<html>
<head>
<title>AngularJs IE11 Test App Host</title>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<style type="text/css">
iframe{
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<h1>AngularJs IE11 Test App Host</h1>
<p>below you see the iframe, where an angular js app is loaded</p>
<iframe src="ie11testapp.html">

</iframe>

</body>
</html>

2.) ie11testapp.html

<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
</head>
<body>
<div><label>Name:</label> <input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
<h1>Hello {{yourName}}!</h1></div>
</body>
</html>
@petebacondarwin
Copy link
Contributor

Would this be related to #4119?

@petebacondarwin
Copy link
Contributor

When I tried this in IE10, it initially told me that the website was trying to run an ActiveX control. When I clicked allow then it all worked fine.

@derbernd86
Copy link
Author

Thank you for your response. In IE10 I got the same behaviour. But IE11 doesn't work at all.
This Bug is critical to me. Do you reflect those problems to Microsoft's IE11 team?
Is there a workaround or a simple bugfix to this issue?

@petebacondarwin
Copy link
Contributor

OK, so the problem is that in angular.forEach: https://github.com/angular/angular.js/blob/master/src/Angular.js#L140
There is a call to obj.hasOwnProperty(key). IE11 in IE8 mode is saying that the obj, which is a DispStaticNodeList object, does not have this method!
It may be that the changes in #3331 will fix this.

@derbernd86
Copy link
Author

Thank you for your answer!
I changed the code of the angular.ForEach in https://github.com/angular/angular.js/blob/master/src/Angular.js#L140

Instead of obj.hasOwnProperty(key)
I changed it to Object.prototype.hasOwnProperty.call(obj, key)
This works for me, but I'm not sure if there are other situations where IE11 documentMode ie8 breaks relying on hasOwnProperty-Method.

I didn't find this change in your fix #3331?

@petebacondarwin
Copy link
Contributor

Hmm, yes, the trouble is that Object.prototype.hasOwnProperty.call(obj, key) is orders of magnitude slower that just calling obj.hasOwnProperty(key) and so my PR tried hard not to change "hot" code.
I think that your situation is so specialized that we cannot implement such a change throughout the core just for it.
I suggest that you have your own fork of the project, where you do a simple search and replace for ".hasOwnProperty(". This should fix your problem.

@mvcninja
Copy link

The error is within the angularInit function, which is using foreach to iterate over the list of dom elements returned from element.querySelectorAll()
IE8 only supports querySelectorAll in standards mode, so this code won't be reached if using IE8 in quirks mode or IE7 compatibility mode. Adding an additional check for element.hasOwnProperty should bypass this code, which shouldn't be needed for IE8 as it's getting the app root by id.

Also, the consoleLog needs to check for typeof logFn === "function". IE8 throws an error on the check for console.log.apply, and IE7-8 returns typeof "object" for methods on the console object.

@orias407
Copy link

orias407 commented Mar 4, 2014

I had the same issue but was solved when I used ngularJS v1.2.14.

@pdorrestijn
Copy link

I tried this with 1.2.14 and 1.3.0 in IE with and without setting X-UA-Compatible.
It does not appear to be fixed to me.

@oliverbenns
Copy link

Same issue here. 1.2.0, with X-UA-Compatible we get the error mentioned. Without X-UA-Compatible it does not render the page and we get no console logs.

@petebacondarwin
Copy link
Contributor

Perhaps you might like to put together a PR with the fix suggested in #4137 (comment) ?
If you can prove it works with tests then it can go into the next 1.2 release.

@jilanirony
Copy link

just add below tag inside your head, it works like charm. IE=11 is the version of IE.

 <meta http-equiv="X-UA-Compatible" content="IE=11" />  

@ppsgppsi
Copy link

jilanirony
just add below tag inside your head, it works like charm. IE=11 is the version of IE.

This worked for me and saved my deadline!

Additionally, IE11 refused to fetch libraries that it didn't "trust" such as

http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js

So i just copied them local. Off to the races!

Thanks Mr. Irony!

@MarkPieszak
Copy link
Member

MarkPieszak commented Jan 13, 2016

Also running into this problem myself.
IE11 document mode 8 just says "Module" is undefined...

@VishnuYelapati
Copy link

Instead of obj.hasOwnProperty(key)
I changed it to Object.prototype.hasOwnProperty.call(obj, key)
This works very fine for me

@mohitqservice
Copy link

mohitqservice commented Sep 27, 2016

Hello,
I am facing,angular2 project not work in IE Brower issue. Any one Please me to resolve this issue.

@MarkPieszak
Copy link
Member

@mohitqservice This is for AngularJS (Angular1)

@CoolSuplex
Copy link

@petebacondarwin I am facing an issue with 'data-content' attribute ONLY in IE(just tried IE11).
AngularJS expression is not getting resolved in IE and is perfectly working in chrome and firefox,
data-content="{{::someCtrl.someArray['sometext']}}"
Any ideas are highly appreciated.
Thanks!!

@petebacondarwin
Copy link
Contributor

@CoolSuplex - you problem does not seem related to this issue. Please open a new issue with a full reproduction of the problem if you feel it is a bug in AngularJS.

@shaareable
Copy link

shaareable commented Apr 8, 2018

In an Angular app, how do I put <meta http-equiv="X-UA-Compatible" content="IE=11" /> below the head?

ps: I am learning to code. Thank you.

@parak80
Copy link

parak80 commented Jul 5, 2018

Hi, you should put the meta tag in the main html file inside the head tag

@parak80
Copy link

parak80 commented Jul 5, 2018

I am using angular cli/angular 5 in my app and it run in IE browser but there are some css/bootstrap that are not following with, like my navbar, some colors that described as default color for buttons: var(); etc. They are not showing. Anyone has solution for this?

@Oscar8401
Copy link

Oscar8401 commented Nov 15, 2018

Hi,
I am facing this problem in IE11, I tried to set below the head, but the issue still exist som fiel are disabled on IE11 from the other side everything working correctly on edge.
Any idea how can I deal with this?

@sdokic
Copy link

sdokic commented Jun 3, 2019

The only fix that I found is to update tsconfig.json file. Change to "target": "es3" from whatever you have in your tsconfig.json.

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