ded / klass

a utility for creating expressive classes in JavaScript
753 stars 78 forks source link

extend doesn't include statics #12

Closed jspies closed 12 years ago

jspies commented 12 years ago

Just using your example,

var klass = require("klass")

var Person = klass(function (name) {
  this.name = name
})
  .statics({
    head: ':)',
    feet: '_|_'
  })
  .methods({
    walk: function () {}
  })

  var SuperHuman = Person.extend(function (name) {
  // super class is automagically called
  })
    .methods({
      walk: function() {
        this.supr()
        this.fly()
      },

      fly: function() {}

    })

new SuperHuman('Zelda').walk()

console.log(Person.head);
console.log(SuperHuman.head);

outputs: :) undefined

Is this by design?

kiall commented 12 years ago

I've just noticed the same thing. It seems like static methods should be included...

ded commented 12 years ago

statics are on the original classes... not inherited. it's unfortunate, but still by design. if you want inheritance, put them on the prototype. thanks for understanding!