rzel / joose-js

Automatically exported from code.google.com/p/joose-js
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

INNER() call renders superclass unusable #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Define two classes.  The first one should have a method that calls 
"this.INNER()", and the second one should be a subclass of the first and 
augment that method.  Using the method in the subclass works, but using the 
method in the superclass throws an error.  For example (attached):

Class('Announcer', {
  has: {
    body: {is: rw, init: ''}
  },
  methods: {
    append: function(appendage) {
      this.setBody(this.getBody() + appendage);
    },
    create: function() {
      this.append('<announcement>');
      this.INNER();
      this.append('</announcement>');
    },
  },
});

Class('BirthAnnouncer', {
  isa: Announcer,
  augment: {
    create: function() {
      this.append('<birth>');
      this.append('Happy birthday!');
      this.append('</birth>');
    },
  },
});

What is the expected output? What do you see instead?

The subclass works as expected:
var works = new BirthAnnouncer();
works.create();
works.getBody(); // returns "<announcement><birth>Happy 
birthday!</birth></announcement>"

The superclass does not work but throws an error:
var breaks = new Announcer();
breaks.create(); // throws an error: "TypeError: Object a Announcer has no 
method 'INNER'"
breaks.getBody(); // is "<announcement>", but should be longer.

What version of the product are you using? On what operating system?

Joose 2.1, unminified, on OS X.5.8.

Please provide any additional information below.

Original issue reported on code.google.com by kyp...@gmail.com on 13 Aug 2010 at 12:48

Attachments:

GoogleCodeExporter commented 9 years ago
I fixed a related issue with three classes instead of two.  See the attachment 
for the example code.  Here is the fix:

$ diff joose.orig.js joose.new.js 
1742c1742
<                 this.INNER    = function () {return  
me.__INNER_STACK__.pop().apply(me, arguments) };
---
>                 this.INNER    = function () { var func = 
me.__INNER_STACK__.pop(); return (func ? func.apply(me, arguments) : func); };

Original comment by kyp...@gmail.com on 13 Aug 2010 at 12:53

Attachments: