Javascript "Member not found" error in IE8

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-03-23T15:17:05Z Indexed on 2010/03/23 15:23 UTC
Read the original article Hit count: 513

Filed under:
|

I'm trying to debug the following block of Javascript code to see what the issue is. I'm getting an error that says "Member not found" on the line

constructor = function() {
in the extend:function() method.

I'm not very good with Javascript, and I didn't write this, so I'm kind of lost on what the issue is. The error only occurs in IE8, it works fine in IE7 and Firefox.

var Class = {
  create: function() {
    return function() {
        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
      }
  },

  extend: function(baseClassName) {
    constructor = function() {
        var i;

          this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }

        if(this.destroy) Class.registerForDestruction(this);
          if(this.initialize) this.initialize.apply(this, arguments);
    }

    constructor.getInheritedStuff = function() {
        this[baseClassName] = {}
        for(i in window[baseClassName].prototype) {
            if(!this[i]) this[i] = window[baseClassName].prototype[i];
            if(typeof window[baseClassName].prototype[i] == 'function') {
                this[baseClassName][i] = window[baseClassName].prototype[i].bind(this);
            }
        }

        if(window[baseClassName].getInheritedStuff) {
            window[baseClassName].getInheritedStuff.apply(this);
        }
    }

    return constructor;

  },

  objectsToDestroy : [],  
  registerForDestruction: function(obj) {
    if(!Class.addedDestructionLoader) {
            Event.observe(window, 'unload', Class.destroyAllObjects);
        Class.addedDestructionLoader = true;
    }
    Class.objectsToDestroy.push(obj);
  },

  destroyAllObjects: function() {
    var i,item;
    for(i=0;item=Class.objectsToDestroy[i];i++) {
        if(item.destroy) item.destroy();
    }
    Class.objectsToDestroy = null;
  }  
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ie8