greetings all,

in trying to create a useful and extensible pattern for JS widget
development, i've stumbled across an apparent bug in the latest
[non-beta] version of Safari: the constructor property is not set
correctly on instances that are created via Class.create(). this bug
makes it difficult to get at the class variables/methods via
this.constructor inside an instance's method without using an ugly
(and probably not even kosher) hack. please see my test page for full
details and test cases:

before i go further, i realize this is (probably) not a
Prototype-specific issue, but since there was so much recent
discussion as to new inheritance methodologies, i figured i'd bring up
the issue on this list. even more so because the new Class.extend()
implementation exhibits the same issue in Safari. (i should mention
that everything is working just fine in the WebKit nightlies.)

my questions are:

- is this a known issue? i've checked open tickets in trac and haven't
come across anything similar.

- am i attempting something that's unconventional (or is there a
better way)? my goal is to have some class variables that are used for
configuration of the class. upon subclassing, the developer would have
the option to override the configuration options for the subclass.
here's a piece of code that illustrates my desired idiom:

- - - - - -
var BaseWidget = Class.create();

Object.extend(BaseWidget, {
  CONFIG : {
    base_prop : "a base prop"

Object.extend(BaseWidget.prototype, {
  initialize : function(var1, var2, config) {
    // ...
    this.CONFIG = Object.extend(Object.clone(this.constructor.CONFIG),
config || {});
    // ...

var MyWidget = Class.create();

MyWidget.CONFIG = Object.extend(Object.clone(BaseWidget.CONFIG), {
  my_prop : "my prop"

Object.extend(Object.extend(MyWidget.prototype, BaseWidget.prototype), {
  newMethod : function() {

var a = new MyWidget();
- - - - - -

hope that makes sense.

so am i misusing and/or misunderstanding the Prototype.js way of
subclassing? should i just do subclassing without Class.create/extend?

TIA for any and all comments. oh, and keep up the brilliant work!


You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to