Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10766 closed bug (invalid)

jQuery.extend does not relate to JavaScript 1.8.5's property description

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


JavaScript 1.8.5 introduced methods like Object.defineProperty, allowing you to set the description of a property. When using jQuery.extend, it does not relate at all to this description, resulting in properties that are not enumerable to not getting copied, and in properties that are not writable or configurable to be writable and configurable.

Tested with Firefox 9, jQuery 1.7 and Windows 7, but I am guessing this bug will occur in every jQuery version with a browser that implemented JavaScript 1.8.5.

Example: http://jsfiddle.net/ZBajX/2/ The result in this example is 'undefined, val2, undefined', while it should be 'val, val, val'.

Change History (3)

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

$.extend is primarily intended as a cross-browser method for our own internal use in copying properties from *plain objects*, although we do expose it for external code that might find it useful.

We have no plans to add features that we do not need internally, since that often leads to performance and size penalties. Feel free to create and release a plugin that implements the features you need.

comment:2 Changed 11 years ago by [email protected]

But the documentation says that it "merge the contents", and contents can be understood as description too.

Another example is that when doing this:

$.extend(myVar, []);

myVar won't get the length property from the array, because it is not enumerable.

comment:3 Changed 11 years ago by Rick Waldron

Just to clarify, your references are slightly inaccurate; JavsScript 1.8.5 is an irrelevant version concept that refers only to Mozilla's JavaScript implementation of EcmaScript. Object.defineProperty was introduced in ES5, but jQuery supports browsers that are barely ES3 compatible - introducing many of the great ES5 and 5.1 features is not realistic for jQuery from a maintenance and sanity perspective. Creating two code paths to allow for two different behaviours that are platform dependent would be absolute chaos.

All of that aside, there is no standard by which extend behaviour is explicitly defined and jQuery has _never_ claimed that it intends to be in parity with ES5

Note: See TracTickets for help on using tickets.