0

Google prettify stops working when my JS file has a Object.prototype.myFunction = function(....

I.e. when I have at least one new function defined inside the Object.prototype, It prevents prettify to show code on my web-page.

Even though, I don't try to show that javasript file inside prettify code viewer. I just use that js-file as a lib.

I wonder why.. and how to avoid this? There is No any error in the browser when it happens

ses
  • 13,174
  • 31
  • 123
  • 226
  • 3
    sounds like prettify is poorly (un-defensively) coded. Use Object.defineProperty(Object.prototype, "myFunction", {value: fn}) to define the method instead of just tacking it onto the prototype. that should keep it from appearing in un-filtered for loops. someone else can beat you up for using object protos... – dandavis Jun 12 '14 at 20:05
  • It helped. Btw. For Arrays.prototype.newFunction - it works. It does not like Object.- only. – ses Jun 12 '14 at 20:10

0 Answers0