0

I'm using Crystal Reports in ASP.NET webforms to show some report files. The framework generates some javascript that which is used for the UI logic.

Un-minified version (using a beautifier): http://pastebin.com/uryjRZF7

The thing that bothers me is that as soon as I do any modification to the array prototype, the script above throws 2 errors. It looks like this in firebug (yes, I know, but I can't un-minify it at this point):

TypeError: E[D].getHTML is not a function

...conWidget("iconMenu_icon_"+C,B,IconMenuWidget_iconClickCB,K,F,J,G,P,L,A,N,false)...

TypeError: A.layer is null

...conWidget("iconMenu_icon_"+C,B,IconMenuWidget_iconClickCB,K,F,J,G,P,L,A,N,false)...

For example, this would make the errors appear:

if(!Array.prototype.somethingVeryUnique) {

    Array.prototype.somethingVeryUnique = function () {

        return this.length;
    };
}

How can this possibly interfer with the auto generated file?!

Update:

Object.defineProperty(Array.prototype, "somethingUnique", {
    enumerable: false,
    writable: true,
    value: function () {

    }
});

If I make it non-enumerable, it works. However, object.defineProperty doesn't work in IE7, which I need to support.

Is there any way to make a non-enumerable property without it?

Johan
  • 35,120
  • 54
  • 178
  • 293
  • @Qantas94Heavy What do you mean by non-filtered? – Johan Dec 16 '13 at 08:53
  • See @HMR's answer, that's what I meant. Since you changed your question, it now seems to be a dupe of [Object.defineProperty in ES5?](http://stackoverflow.com/questions/3830800/object-defineproperty-in-es5) :( – Qantas 94 Heavy Dec 16 '13 at 08:55
  • @Qantas94Heavy Well, a part of it is. But I wouldn't call this a dupe. – Johan Dec 16 '13 at 09:13

1 Answers1

1

They are probably using for(something in array) and the prototype added member will show up if you don't check array.hasOwnProperty(something); Best is to not extend native JS objects.

HMR
  • 37,593
  • 24
  • 91
  • 160
  • Well, extending native types comes down to personal preferences. Extending `Object` *is* bad. However, `String`, `Array` etc can be useful in my optinion. But I suppose you're right about the looping. Thanks – Johan Dec 16 '13 at 09:09