Skip to main content

Bug Tracker

Side navigation

#5660 closed bug (invalid)

Opened December 15, 2009 02:34PM UTC

Closed December 16, 2009 12:41AM UTC

$.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!!!

Attachments (0)
Change History (1)

Changed December 16, 2009 12:41AM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed
$.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.