Opened 10 years ago

Closed 6 years ago

#13864 closed enhancement (patchwelcome)

dojo.declare does not properly handle get set accessors

Reported by: David Rees Owned by: Eugene Lazutkin
Priority: high Milestone: 1.13
Component: Core Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:


dojo.declare does not seem to properly bind get/set accessors to the right instance. The following code demonstrates the problem. I believe the line with the comment should return 5 rather than 4. I think it returns 4 because the this in the get is improperly bound.

For reference, here are the Classy.js code changes to properly support get/set accessors -

dojo.declare("test.Cat", null, {
        meow: function() { return "meow"; },
        get legs() { return this._legs },
        set legs(n) { this._legs = n},

var cat = new test.Cat();
q.equal(cat.meow(), "meow");
cat.legs = 4;
q.equal(cat.legs, 4);
cat._legs = 5;
q.equal(cat.legs, 4); // This is wrong, should be 5
var cat2 = new test.Cat();
q.equal(cat2.legs, undefined);

Change History (3)

comment:1 Changed 10 years ago by bill

Component: GeneralCore
Owner: set to Eugene Lazutkin

comment:2 Changed 10 years ago by Eugene Lazutkin

Type: defectenhancement

comment:3 Changed 6 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: newclosed

Given that no one has shown interest in creating a patch in the past 4+ years, I'm closing this as patchwelcome.

Note: See TracTickets for help on using tickets.