benhowdle89 / Class

Simple, elegant inheritance for your JavaScript
http://benhowdle.im/Class
MIT License
1 stars 1 forks source link

Parents getting child properties #2

Open jackfranklin opened 10 years ago

jackfranklin commented 10 years ago
var Class = require("node-classjs");

var Parent = Class().extend({
  foo: 2
});

var bob = new Parent();

var Child = bob.extend({
  bar: 3
});

var alice = new Child();

console.log("bob.foo", bob.foo); // 2, as expected
console.log("alice.foo", alice.foo); // 2, as expected

console.log("bob.bar", bob.bar); // 3??? Bob shouldn't have a bar property?
console.log("alice.bar", alice.bar); // 3, as expected

I don't think bob.bar should exist. The parent shouldn't get properties of the child...

jackfranklin commented 10 years ago

I fixed this on my fork, see what you think, can always make a PR: https://github.com/jackfranklin/Class/commit/d308c33ff401521ac1f609009e4de90b2b790050

benhowdle89 commented 10 years ago

It works, so let's PR it!