premasagar / pablo

Pablo is a lightweight, expressive JavaScript SVG library. Pablo creates interactive drawings with SVG (Scalable Vector Graphics), giving access to all of SVG's granularity and power.
https://pablojs.com
MIT License
413 stars 16 forks source link

Pablo.extend() deep does not copy over all properties #54

Closed AaronAcerboni closed 11 years ago

AaronAcerboni commented 11 years ago

The deep flag in extend does not fully copy over all properties.

Steps to reproduce:

var obj1 = {
  animal: "dog",
  about: {
    legs: 4
  }
},
obj2 = {
  name: "rex",
  about: {
    attitude: "friendly"
  }
};

var merged = Pablo.extend(obj1, obj2, true);

// Expected object:

{
  animal: "dog",
  name: "rex",
  about: {
    legs: 4,
    attitude: "friendly"
  }
}

// Actual object:

{
  animal: "dog",
  name: "rex",
  about: {
    attitude: "friendly"
  }
}
premasagar commented 11 years ago

It copies over properties in the prototype chain:

function Foo(){}
Foo.prototype = {bar:1};
Pablo.extend({}, new Foo()); // {}
Pablo.extend({}, new Foo(), true); // {bar:1}
AaronAcerboni commented 11 years ago

committed 46d9746