Comparing version 1.0.1 to 1.0.2
@@ -16,3 +16,3 @@ module.exports = extends_; | ||
for (var key in Parent) { | ||
if (Parent.hasOwnProperty(key)) { | ||
if (!Child.hasOwnProperty(key) && Parent.hasOwnProperty(key)) { | ||
Child[key] = Parent[key]; | ||
@@ -19,0 +19,0 @@ } |
{ | ||
"name": "typedef", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Low-level type-centric utility functions for Javascript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -114,1 +114,24 @@ var extends_ = require('../lib/extends.js'); | ||
}); | ||
test('Static member overriden by child', function(t) { | ||
t.plan(2); | ||
var A = 'A'; | ||
var B = 'B'; | ||
function Parent() { } | ||
Parent.foo = A; | ||
// Trivial case of extends being called first | ||
function Child() { } | ||
extends_(Child, Parent); | ||
Child.foo = B; | ||
t.strictEqual(Child.foo, B, 'Child foo'); | ||
// Using extends aftewards should skip over any statics already on child | ||
function Child2() { } | ||
Child2.foo = B; | ||
extends_(Child2, Parent); | ||
t.strictEqual(Child2.foo, B, 'Child2 foo'); | ||
}); |
14925
302