tests-always-included / pretty-js

Beautify and pretty print JavaScript and JSON
Other
21 stars 4 forks source link

"constructor" missing #5

Closed fidian closed 10 years ago

fidian commented 10 years ago

After pretty printing code I found that this line gets pretty printed weird.

$delegate.constructor.prototype.$onRootScope = function (name, listener) {

Result:

$delegate..prototype.$onRootScope = function (name, listener) {

Where did "constructor" go?

fidian commented 10 years ago

Found the issue. I was setting up handlers in an object. I used a token's content ("constructor" in this case) to select which handler to run. Unfortunately, the object natively has a .constructor property and my code was executing that instead. I now check that my object has its own property, not an inherited property.