xuijs / xui

A tiny javascript framework for mobile web apps.
http://xuijs.com
787 stars 106 forks source link

Enhance xui's extend() by allowing it to copy plain javascript objects #53

Closed i8ramin closed 12 years ago

i8ramin commented 12 years ago

XUI's base extend function only extends the xui prototype. With this new functionality, if more 2 objects are passed in, then the first object is extended with the properties of the 2nd object. This also does a Deep Copy.

filmaj commented 12 years ago

My only beef with this addition is that it adds another ~200 bytes to the minified code...

Is the two-argument functionality something that would be used somewhat? I would love to hear input from anyone else keeping tabs on this project...

i8ramin commented 12 years ago

We use this functionality a lot in our code base, to extend regular "non-xui" objects. Like extending a set of default properties with a passed in one. At first I created a $.fn.extendObj() function, but then realized that we could simply use the existing $.fn.extend and make it a bit smarter (jquery also does this) - we can remove the "deep cloning" feature and cut down on the size a bit, but I personally feel like it is a useful feature to have.

filmaj commented 12 years ago

Doesn't look like there's much of a need for this. I think it's safer to keep the codebase small.