Skip to content

jQuery.merge: add note about it correcting the length #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

arthurvr
Copy link
Member

Fixes #686

@arthurvr
Copy link
Member Author

arthurvr commented Apr 2, 2015

@mzgol WDYT?

@mgol
Copy link
Member

mgol commented Apr 7, 2015

The page still mentions that jQuery.merge merges two arrays (and does it in multiple places). This should all be changed to mention array-likes. Apart from that, the change looks fine (modulo the outcome of #686 (comment)).

@arthurvr arthurvr force-pushed the lengthMerge branch 2 times, most recently from 44072ae to 64a6b90 Compare April 16, 2015 21:18
@arthurvr
Copy link
Member Author

So, I updated the entry to use the array-like object type so we don't need to get funky explaining why we correct the length. What do we think?

When updating it I noticed a little issue with 929f9e2, I called the type array-like objects but it should be array-like object. Sorry! Fixed that in a separated commit.

@mgol
Copy link
Member

mgol commented Apr 17, 2015

I don't see it mentioned anywhere in the docs that if jQuery modifies an array-like object, its length gets corrected. This would fit perfectly here, though so I'd leave this text.

@arthurvr
Copy link
Member Author

@mzgol Updated that. Thanks! At first it sounded quite logical to me so I didn't find an explicit note necessary, but yeah, you're right. WDYT?

@@ -19,6 +19,7 @@ var newArray = $.merge([], oldArray);
</code></pre>
<p>This shortcut creates a new, empty array and merges the contents of oldArray into it, effectively cloning the array.</p>
<p>Prior to jQuery 1.4, the arguments should be true Javascript Array objects; use <code>$.makeArray</code> if they are not.</p>
<p>Because <code>jQuery.merge()</code> is capable of merging array-like objects it will correct the <code>length</code> property.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a comma before "it". But this note might be better placed near "is destructive" anyway, something like "It alters the length and numeric index properties of the first parameter to include items from the second."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibson042 Sounds good. PTAL.

@gibson042
Copy link
Member

LGTM.

@arthurvr arthurvr closed this in c0e5d54 Apr 17, 2015
@arthurvr arthurvr deleted the lengthMerge branch April 17, 2015 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

jQuery.merge: add note about it correcting the length property
4 participants