Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix JS Quick Edit for projects that have a function named "hasOwnProperty" #3004

Merged
merged 5 commits into from
Mar 28, 2013

Conversation

gruehle
Copy link
Member

@gruehle gruehle commented Mar 1, 2013

Fixes #3002

If any files in your project define a function named hasOwnProperty, JS Quick Edit would throw an exception. (modernizr.js, which is included in the test files for phantom.js, defines a hasOwnProperty function. This is the cause of bug #3002).

@peterflynn - since you've fixed several bugs in this area, would you mind taking a look?

@ghost ghost assigned peterflynn Mar 1, 2013
@peterflynn
Copy link
Member

I think this is basically plugging a hole in my earlier fix #2816 (sorry!). That patch made a similar []->hasOwnProperty() conversion in StringMatch too (https://github.com/adobe/brackets/pull/2816/files#L3L792) -- seems like this fix should also apply there?

It would also be good to augment the unit tests that #2816 added (https://github.com/adobe/brackets/pull/2816/files#L6R255 and https://github.com/adobe/brackets/pull/2816/files#L6R443 and https://github.com/adobe/brackets/pull/2816/files#L8R634) to cover this bug too.

@peterflynn
Copy link
Member

I'd bet we have similar bugs with some of the other built-in Object properties (constructor, isPrototypeOf, valueOf, etc.)... worth trying to fix those here, or should we just do a spin-off bug?

[Edit: or maybe not... I guess the original #2816 fix should in theory cover all cases except for hasOwnProperty() already]

@peterflynn
Copy link
Member

One other thought: if we're using this hasOwnProperty.apply() trick in a few places, is it worth adding a utility fn for it? (CollectionUtils maybe?)

@peterflynn
Copy link
Member

@gruehle done reviewing

@gruehle
Copy link
Member Author

gruehle commented Mar 22, 2013

@peterflynn - thanks for the review! I've made all your suggested changes. Ready for re-review.

@TomMalbran
Copy link
Contributor

Hehe, JSHint doesn't like the hasOwnProperty name maybe we can call it hasProperty?

…Hint correctly stated: 'hasOwnProperty is a really bad name.'
@gruehle
Copy link
Member Author

gruehle commented Mar 22, 2013

Yep :-). This is one case where JSHint complained more than JSLInt. Changed to "hasProperty".

@TomMalbran
Copy link
Contributor

It kind of makes sense, since we are fixing the problem of a project having a hasOwnProperty function by adding a hasOwnProperty function. Maybe JSLint should complain about it too.

@peterflynn
Copy link
Member

Looks good!

peterflynn added a commit that referenced this pull request Mar 28, 2013
Fix JS Quick Edit for projects that have a function named "hasOwnProperty"
@peterflynn peterflynn merged commit 0a2d421 into master Mar 28, 2013
@peterflynn peterflynn deleted the glenn/issue-3002 branch March 28, 2013 18:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS Quick Edit doesn't work if you have a function named "hasOwnProperty" in your source
3 participants