Backbone.ModelMorph icon indicating copy to clipboard operation
Backbone.ModelMorph copied to clipboard

not compatible with lodash

Open jiixing opened this issue 12 years ago • 1 comments

lodash _.extend behave differently when copying method attribute, so I patch in underscore extend. This is for user who are using frameworks like chaplin.js that come predefined with backbone and lodash

   };

   Backbone.Morph = function (model, schema) {
+
+
+    var old_extend = function (obj) {
+        _.each(_.toArray(arguments).slice(1), function(source) {
+          if (source) {
+            for (var prop in source) {
+              obj[prop] = source[prop];
+            }
+          }
+        });
+        return obj;
+    }
+
+
     // create a new Morph model that uses the original model as a prototype
     var Morph = function() {};
-    _.extend(Morph.prototype, model, proto);
+    old_extend(Morph.prototype, model, proto);
+
     var morph = new Morph();
     morph._schema = schema;
     morph._model = model;


jiixing avatar Dec 09 '13 23:12 jiixing

looks good to me, can you send a pull request?

rhysbrettbowen avatar Dec 10 '13 00:12 rhysbrettbowen