Opened 13 years ago
Closed 13 years ago
#5660 closed bug (invalid)
$.extend does not copy own property of form element
Reported by: | telensky | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | core | Version: | 1.3.2 |
Keywords: | extend | Cc: | |
Blocked by: | Blocking: |
Description
If I assign property 'form_idx' to the form element and then use $.extend(), the property is not copied! See testcase available at http://artax.karlin.mff.cuni.cz/~ttel5535/WEB_development/BUGS/091215-jquery_extend/jq_err_simple.html
I would expect the secold alert to say that form_idx is 123.
The snip of the code:
var fe = $('form').get(0);
fe.form_idx = 123;
alert('this.form_idx == ' + fe.form_idx + ', OwnProperty == ' + fe.hasOwnProperty('form_idx'));
b = $.extend({}, fe);
alert('b.form_idx == ' + b.form_idx); how comes that this is undefined!!!
Note: See
TracTickets for help on using
tickets.
$.extend()
is not meant to copy or extend DOM elements. If you want to make a copy of a DOM element, use$(el).clone()
and not$.extend()
. IE in particular doesn't treat a DOM element the same as a Javascript object.