bizcad
bizcad

Reputation: 108

breeze.debug.js javascript error

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?

Upvotes: 1

Views: 1558

Answers (2)

Ward
Ward

Reputation: 17863

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\}\)

Upvotes: 3

Jay Traband
Jay Traband

Reputation: 17052

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"/>

Upvotes: 3

Related Questions