1

I have been building a SPA with breeze and WebAPI (starting with John Papa's sample) for a couple of months. A couple of days ago on my Windows 8 VS2012 internal IE browser started giving me javascript errors in breeze.debug.js.

JavaScript critical error at line 4663, column 13 in //http://localhost:50033/Script/breeze.debug.js

SCRIPT1028: Expected identifier, string or number

I went back to my other development machine, Windows 7 with VS2012 and it does not give the error. The code between the two machines is identical. I use Azure TFS to sync the code.

The error occurs at the closing });

        function convertFromODataEntityType(odataEntityType, schema, metadataStore, serviceName) {
        var shortName = odataEntityType.name;
        var namespace = translateNamespace(schema, schema.namespace);
        var entityType = new EntityType({
            shortName: shortName,
            namespace: namespace, 
        });                          <==== line 4663

When I remove the comma after namespace, the error goes away but errors out again in another spot on line 6911.

        day:         { fn: function(source) { return source.day;}, dataType: "Number" },
        month:       { fn: function(source) { return source.month; }, dataType: "Number" },
        year:        { fn: function(source) { return source.year; }, dataType: "Number"},
    };             <========= line 6911

Remove the comma on the line above and it errors out on line 1271

Unhandled exception at line 1271, column 17 in http://localhost:50033/Scripts/breeze.debug.js

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'some'

at this code:

function compile(self) {
    if (!self._compiledFn) {
        // clear off last one if null 
        if (self._fns[self._fns.length - 1] == null) {
            self._fns.pop();
        }
        if (self._fns.length === 0) {
            return undefined;
        }
        self._compiledFn = function (that, v) {
            return that._fns.some(function (fn) {
                return fn(that, v);
            });
        };
    };
    return self._compiledFn;
}

Has anyone else seen this behavior?

bizcad
  • 108
  • 8

2 Answers2

3

Just a guess, but check that you are not running IE in 'compatability' mode. The 'some' method is part of the ES5 standard and is not available in 'compatability' mode.

To avoid compatability mode issues with IE browsers, we highly recommend adding the following to your HTML header:

<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • Thanks! This worked. Here is how I did it. I added a new item HtmlPage1.html. I added the meta tag and set the page to the start page for the project. I started the project. I clicked the Alt key to bring up the menu bar. I clicked Tools and then Compatibility View Settings. I unchecked both Display all websites in Compatibility View and Display intranet sites in Compatibility View. Most important, I removed local host from the Websites you've added to Compatibility View list box. Then I clicked Close stopped debugging. I reset the Start Page back to index.chtml, clicked F5. Viola! – bizcad Jan 06 '13 at 21:46
  • 1
    this question's answer shows pictures. http://stackoverflow.com/questions/13284083/ie10-renders-in-ie7-mode-how-to-force-standards-mode/13287226#13287226 – bizcad Jan 06 '13 at 21:51
  • Those are good tips, bizcad. I've been hard pressed to understand why I keep getting thrown into compatibility mode for no apparent reason. The meta tag saves me but you've laid down some clues to underlying causes. – Ward Jan 07 '13 at 04:39
3

I've run into it too. In fact, I often do this to myself, especially when deleting or reordering the last k/v pair during development.

While IE10 and other browsers are more forgiving, we should eliminate trailing commas on our hashmap object key/value lists ... and will do so.

FWIW, the following regex expression finds them all

,(\s*)\}\)

and the following regex substitution pattern fixes them (preserving whitespace):

$1\}\)
Ward
  • 17,793
  • 4
  • 37
  • 53
  • Thanks Ward. I found a few of these in my code and changed them. Unfortunately there are a bunch in breeze.debug.js. Minification may have taken care of it. Jay's answer got the check mark because I can only check one but you deserve one too. Thanks for the help. I may not be able to +1 you will try. – bizcad Jan 06 '13 at 21:49