ericmbarnard/Knockout-Validation — Issue #17: extend functions
Author: michalporeba
Created: 2012-01-30 15:05:18+00:00
State: open

This is just an idea of code (and coding) simplification.

at the moment there are two extend functions when one works with knockout.validation
* `ko.utils.extend()` - from original knockout
* `ko.validation.utils.extend()` - from the extension
and if one assumes that most people using the two use also jQuery at least from time to time, there is also
* `jQuery.extend()`

the not obvious problem is that not only the three functions are implemented differently but the actually do different things.

`jQuery.extend()` is by far most advanced, accepts many sources and can perform truly deep copies. It doesn't copy undefined properties and makes sure it is always copying values not references
`ko.utils.extend()` performs only quick shallow copy of immediate properties of the only one source object. the only check id does is `hasOwnProperty`
`ko.validation.utils.extend()` is a strange hybrid that takes up to two sources and copies properties of the immediate properties and properties of properties. But it is not recursive so third level properties will not be processed.

obviously there is no point adding dependency on massive jQuery library just to have one function available, especially that one of the nicities of knockout is that is self contained. But how about either using ko.utils.extend or if it is for any reason impossible (for example you need the second level properties) maybe we could suggest changes to `ko.utils.extend()` implementation?