bugease.js - Bugs: bug #38255, Property assignments of extended...

 
 

bug #38255: Property assignments of extended prototypes (non-class)

Submitted by:  Mike Gerwitz <mikegerwitz>
Submitted on:  Mon 04 Feb 2013 06:14:25 PM UTC  
 
Category: CoreSeverity: 4 - Important
Priority: 5 - NormalItem Group: Development
Status: ConfirmedPrivacy: Public
Assigned to: Mike Gerwitz <mikegerwitz>Percent Complete: 0%
Open/Closed: OpenRelease: 0.1.0
Operating System: NonePlanned Release: 
Fixed Release: Runtime Environment: All
Runtime Environment Version: 
Keywords: inheritance, prototypes

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 04 Feb 2013 06:14:25 PM UTC, original submission:

Consider this situation:

function Foo()
{
}

Foo.prototype.bar = function( val )
{
this.foo = val;
}

var Foo2 = Class( 'Foo2' ).extend( Foo,
{
'public setBar': function( val )
{
this.bar( val );
},

'public getBar': function()
{
return this.foo;
},
} );

Now, consider that we have:

var foo = Foo2();
foo.bar( 'moo' );
foo.foo // "moo"
foo.getBar() // "moo"

foo.setBar( 'baz' );
foo.foo // "moo"
foo.getBar() // "baz"

The problem is that 'foo' isn't defined as a property on the prototype---it is simply assigned during a method call. This is a problem because ease.js therefore does not create a proxy to it and, as such, the context (bound to 'this') is the private visibility object when Foo.bar() is called within the scope of the class. However, when it's called outside the scope of the class, it is the public visibility object.

With the understanding that these properties would be implicitly public in pure ECMAScript, it may suffice to simply have ease.js wrap each method of the prototype being inherited (if it recognizes that it is not a class), which would then ensure that 'this' references the public visibility object. Of course, that would mean that the supertype would not have access to protected members.

Mike Gerwitz <mikegerwitz>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mikegerwitz (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1