Side navigation
#10766 closed bug (invalid)
Opened November 12, 2011 02:37AM UTC
Closed November 12, 2011 02:52AM UTC
Last modified November 12, 2011 07:55PM UTC
jQuery.extend does not relate to JavaScript 1.8.5's property description
Reported by: | tamir.z3@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
JavaScript 1.8.5 introduced methods like [[https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty|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'.
Attachments (0)
Change History (3)
Changed November 12, 2011 02:52AM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed November 12, 2011 06:38PM UTC by comment:2
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.
Changed November 12, 2011 07:55PM UTC by comment:3
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
$.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.