MatthewMueller/cheerio — pull request #290 by jugglinmike (2013-10-30 01:15:39+00:00)
Title: Implement function signature for manipulation methods

Filling out a few more of the "pending" tests.

More significantly, I made some modifications to the internal `makeCheerioArray` function:

- I made a small optimization: it now works recursively on the supplied values. This saves Cheerio from having to needlessly `flatten` already-flat arrays and also removes the need to wrap non-array-like arguments in array literals (as [Cheerio currently does in one case](https://github.com/MatthewMueller/cheerio/blob/2a643e68ee21aac579d833f1e6b05f26197ff89f/lib/api/manipulation.js#L118), and this changeset [needed](https://github.com/jugglinmike/cheerio/commit/069dad81adf4180f8697a2a662ce882163c66fff) to [do](https://github.com/jugglinmike/cheerio/commit/d5765cc7d38b802638e4598713cdbb295cdaa6d2) as [well](https://github.com/jugglinmike/cheerio/commit/13af62a1e97760f6f8defafccaa9da965947c667)).
- I renamed it to `makeDomArray` to more clearly describe what it's doing.
- I modified the semantics slightly: it now accepts `undefined` and `null`. Previously, these values would raise an exception when Cheerio attempted to dereference them (as in `elem.cheerio`). By special-casing them, we will see behavior that is slightly more consistent with jQuery itself--calling `$el.append(null)`/`$el.after(undefined)` will not raise an exception. I didn't add explicit tests for this because it's not documented anywhere.

The new functionality works without the change to `makeCheerioArray`, so if it doesn't make sense for some reason, I can easily toss [the last commit on this branch](https://github.com/jugglinmike/cheerio/commit/091f0ac8664662d095b101e874cca4e3bd7e8991).