#2721 closed bug (wontfix)
Object.prototype
Reported by: | dryabkov | Owned by: | john |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | core | Version: | 1.4.4 |
Keywords: | hasOwnProperty, object.prototype | Cc: | |
Blocked by: | Blocking: |
Description
<html> <head> <script type="text/javascript"> Object.prototype.test1 = function() {alert('sss')}; </script> <script src="js/jquery-1.2.3.js" ></script> </head> <body> </body> </html>
In Firefox2 and Konqueror test1 considered as event handler and called on page refresh (handling event "unload").
Change History (20)
comment:1 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 14 years ago by
Component: | event → core |
---|---|
Milestone: | 1.2.4 → 1.3.2 |
Resolution: | invalid |
Status: | closed → reopened |
Version: | 1.2.3 → 1.3.1 |
I'm going to re-open this so that we can try and tackle it in a future release.
comment:3 Changed 14 years ago by
Owner: | set to john |
---|---|
Status: | reopened → new |
comment:4 Changed 14 years ago by
comment:5 Changed 14 years ago by
Milestone: | 1.3.2 → 1.3.3 |
---|
comment:6 follow-up: 13 Changed 14 years ago by
Fix should be easy:
for (var i in O) { if (!O.hasOwnProperty(i)) { continue; } // other code stays unchanged }
The only two problems are:
1.) IE 5.0 and older don't support {}.hasOwnProperty() - but this can be implemented using Object.prototype ...
2.) Find all the for-in-loops ;)
comment:7 Changed 12 years ago by
Milestone: | 1.4 |
---|---|
Priority: | major → low |
comment:8 Changed 12 years ago by
Keywords: | hasOwnProperty object.prototype added |
---|---|
Milestone: | → 1.5 |
Status: | new → assigned |
I don't think this was meant to be changed to 'new' - switching back to open.
comment:10 Changed 12 years ago by
Milestone: | 1.5 → 1.next |
---|---|
Version: | 1.3.1 → 1.4.4 |
comment:13 Changed 12 years ago by
Replying to Cheatah:
Fix should be easy:
for (var i in O) { if (!O.hasOwnProperty(i)) { continue; } // other code stays unchanged }The only two problems are:
1.) IE 5.0 and older don't support {}.hasOwnProperty() - but this can be implemented using Object.prototype ...
2.) Find all the for-in-loops ;)
For 1.), it's as simple as adding a jQuery-local function for hasOwnProperty
(or even $.hasOwnProperty
), similar to this:
function hasOwnProperty(object, prop) { if (Object.prototype.hasOwnProperty) { return Object.prototype.hasOwnProperty.call(object, prop); } return true; // or a suitable implementation, if one can be implemented easily -- I had seen a good one once, but can't find it now that I need it }
Then, use this function in $.each
, and convert all other for-in loops to use $.each
instead (or use this function in each of those, if that's preferable). Win-win?
comment:14 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
This isn't something that we're going to fix: http://docs.jquery.com/Won%27t_Fix
Modifying Object.prototype is an extremely bad practice. jQuery is not supported on any page where this occurs.