Skip to main content

Bug Tracker

Side navigation

#6145 closed bug (wontfix)

Opened February 22, 2010 06:01AM UTC

Closed November 19, 2010 09:55PM UTC

Last modified January 01, 2014 01:09AM UTC

Extend does not copy property getters

Reported by: arobinson Owned by:
Priority: undecided Milestone: 1.4.2
Component: core Version: 1.4.1
Keywords: extend Cc:
Blocked by: Blocking:

jQuery.extend copies property getter return values, not their code.

To reproduce:

var a = { get test() { return "hi"; }};
var b = $.extend({}, a);
// Correctly prints out the function:
// Incorrectly is undefined:
Attachments (0)
Change History (3)

Changed November 19, 2010 09:55PM UTC by snover comment:1

priority: → undecided
resolution: → wontfix
status: newclosed

Not all browsers supported by jQuery support ES5. Additionally, I doubt so many people are using getter/setters at this point that it is worth adding to core. Feel free to make your own $.extend that uses getOwnPropertyDescriptor to do this, though.

Changed January 01, 2014 12:26AM UTC by anonymous comment:2

Worth reopening? Getters and setters are much more useful now than 3 years ago.

Changed January 01, 2014 01:09AM UTC by dmethvin comment:3

This is not in scope for the applications of $.extend. Create your own or use libraries like underscore/lodash.