tnhu / jsface

Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main(), singleton, super call, private, mixins, plugins, AOP and more.
MIT License
301 stars 46 forks source link

$statics do not work #29

Closed caetanator closed 9 years ago

caetanator commented 9 years ago

$statics do not work in 2.4.0 and 2.4.1 on Google Chrome 42.0.2311.135.

All static methods and properties are undefined on derived objects

Code:

"use strict"; // Activates ECMA JavaScript 5 strict mode

    var Person = Class({
          $statics: {
            MIN_AGE:   1,
            MAX_AGE: 150,

            isValidAge: function(age) {
              return age >= this.MIN_AGE && age <= this.MAX_AGE;
            }
          },

          constructor: function(name, age) {
            this.name = name;
            this.age  = age;
          }
        });

        var person = new Person("Rika", 20);

        Person.MIN_AGE === person.MIN_AGE;               // person.MIN_AGE == undefined
        Person.MAX_AGE === person.MAX_AGE;               // person.MAX_AGE== undefined
        Person.isValidAge(0);                            // false 
        person.isValidAge(person.age);                   // person.isValidAge== undefined.
tnhu commented 9 years ago

Jose,

Since 2.4.0, static properties are available on class only and not on instances (@see https://github.com/tnhu/jsface/issues/25).