1

I am getting following error on my IE 8 page (The page is running fine in other browsers).

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Wed, 10 Sep 2014 06:48:45 UTC

Message: Object doesn't support this property or method
Line: 70532
Char: 5
Code: 0

When I checked the line 70532 in the file mentioned, i saw this code:

if (!Object.create && !Object.create(null).hasOwnProperty) {
      throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg");
    }

What does it meant by Please polyfil with es5-sham:

 Please polyfil with es5-sham: http://git.io/yBU2rg

enter image description here

How can I fix this error.

SharpCoder
  • 18,279
  • 43
  • 153
  • 249

2 Answers2

4

Object.create is not supported in IE8, therefore your framework is asking you to "polyfil" it, which means you need to implement something which should have been supported natively, but for some reason, this particular environment doesn't know about it.

It means, if you want to use Object.create you have to implement it yourself. Fortunatelly, you don't have to do much, the url ( https://github.com/es-shims/es5-shim/blob/master/es5-sham.js) points to a file which contains the neccesary polyfills. Just run that script before your framework script does.

update:
This line seems broken to me: !Object.create && !Object.create(null).hasOwnProperty.
If Object.create is not there, calling it like Object.create(null) should throw an error, but I think it should be something like 'undefined is not a function'.

  • Thank you for quick reply. Even after including the polyfil js , i am getting the same error at the same line – SharpCoder Sep 10 '14 at 08:25
  • wait, is this line from your framework source code? `!Object.create && !Object.create(null).hasOwnProperty`, because it seems broken to me. If `Object.create` is not there, calling it like `Object.create(null)` should throw an error, but I think it should be something like 'undefined is not a function'. Are you sure that is the line which causes the problem? –  Sep 10 '14 at 08:32
  • The problem is with the framework code. When i get error, the error contains the line no which point to this line. – SharpCoder Sep 10 '14 at 08:37
  • hmmm, the error says "Line: 70532". How did you find out which script was causing the error? Because from what you've posted I have no idea where line 70532 is. Did you double click on it and it sent to to that particular line, in that particular script file? (I'm not able to run an IE8 browser instance right now, so I can only guess how that environment behaves) –  Sep 10 '14 at 08:47
  • Thank you for the help. I have added a screenshot which tells the filename and the line on which error occurred. The polyfil I mentioned in my question did not help me. But thank you for explaining what a polyfil is. I googled and found another polyfil which is doing the trick for me. I am upvoting your answer. Cheers – SharpCoder Sep 10 '14 at 08:56
1

I found another polyfil which is working in my scenario. I found the answer at this link.

I am adding code form that link

if (!Object.create) {
    Object.create = function(proto, props) {
        if (typeof props !== "undefined") {
            throw "The multiple-argument version of Object.create is not provided by this browser and cannot be shimmed.";
        }
        function ctor() { }
        ctor.prototype = proto;
        return new ctor();
    };
}

adding this code seems to be doing trick for me. Only change I made is, I commented the code where exception is thrown as it is resulting in another error.

Community
  • 1
  • 1
SharpCoder
  • 18,279
  • 43
  • 153
  • 249