Side navigation
#2721 closed bug (wontfix)
Opened April 19, 2008 11:02AM UTC
Closed July 11, 2011 05:19PM UTC
Last modified August 10, 2014 01:10AM UTC
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").
Attachments (0)
Change History (20)
Changed April 19, 2008 02:22PM UTC by comment:1
| resolution: | → invalid |
|---|---|
| status: | new → closed |
Changed February 10, 2009 10:33PM UTC by comment:2
| 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.
Changed February 10, 2009 10:33PM UTC by comment:3
| owner: | → john |
|---|---|
| status: | reopened → new |
Changed February 10, 2009 11:32PM UTC by comment:4
Changed July 15, 2009 08:51AM UTC by comment:5
| milestone: | 1.3.2 → 1.3.3 |
|---|
Changed July 24, 2009 02:50PM UTC by comment:6
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 ;)
Changed October 25, 2010 11:26PM UTC by comment:7
| milestone: | 1.4 |
|---|---|
| priority: | major → low |
Changed October 26, 2010 06:48AM UTC by comment:8
| keywords: | → hasOwnProperty, object.prototype |
|---|---|
| milestone: | → 1.5 |
| status: | new → assigned |
I don't think this was meant to be changed to 'new' - switching back to open.
Changed October 26, 2010 03:53PM UTC by comment:9
Additional test: http://jsfiddle.net/rwaldron/F8UKY/2/
Changed January 14, 2011 11:45PM UTC by comment:10
| milestone: | 1.5 → 1.next |
|---|---|
| version: | 1.3.1 → 1.4.4 |
Changed January 14, 2011 11:52PM UTC by comment:11
#7977 is a duplicate of this ticket.
Changed January 14, 2011 11:53PM UTC by comment:12
Yet another test case (extracted from 7977)
Changed April 21, 2011 02:11AM UTC by comment:13
Replying to [comment:6 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?
Changed July 11, 2011 05:19PM UTC by comment:14
| resolution: | → wontfix |
|---|---|
| status: | assigned → closed |
This isn't something that we're going to fix:
Changed December 18, 2011 03:22PM UTC by comment:15
#11053 is a duplicate of this ticket.
Changed April 20, 2012 03:14AM UTC by comment:16
#11605 is a duplicate of this ticket.
Changed July 16, 2012 09:11PM UTC by comment:17
#12090 is a duplicate of this ticket.
Changed March 27, 2013 01:33AM UTC by comment:18
#13671 is a duplicate of this ticket.
Changed April 04, 2013 05:58PM UTC by comment:19
#13731 is a duplicate of this ticket.
Changed August 10, 2014 01:10AM UTC by comment:20
#15208 is a duplicate of this ticket.
Modifying Object.prototype is an extremely bad practice. jQuery is not supported on any page where this occurs.