Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#4770 closed defect (invalid)

Can't override Dictionary.add(key, value)

Reported by: guest Owned by: Tom Trenka
Priority: high Milestone:
Component: Dojox Version: 0.9
Keywords: Cc: [email protected]
Blocked By: Blocking:



I've created a test class like this:



dojo.declare( "dojo.Test",



add: function(thekey, thevalue) {




Import as follows:


Create a new instance and invoke Test.add() like this:

var test = new dojo.Test(); test.add("key", "value");

The alert never gets triggered. Thoughts?


Change History (3)

comment:1 Changed 15 years ago by Adam Peller

Component: GeneralDojox
Owner: changed from anonymous to Tom Trenka

comment:2 Changed 15 years ago by Tom Trenka

Resolution: invalid
Status: newclosed

It's very possible that the reason for this is because the entire Collections set is based on closures and private functions, as opposed to using a mixin object on the prototype. This is because of the desire to keep internal lists private and away from the developer, and was by design.

Because of this, you're seeing an unintended effect where your override is really being impressed on the prototype of your new object, which doesn't have any access to the internal method or variable definitions.

So then this is actually by I'm going to close the ticket. If you'd like help designing a similar class for your own use, hit the forums under DojoX ( and I'll help you out there, since I'm sure others will be interested as well.

comment:3 Changed 15 years ago by guest

Why close the ticket though? Why not just leave this open until it gets fixed? We could create a DictionaryWrapper? with an add method that can be overridden and that delegates to Dictionary.add(). This takes 2 seconds, and solves it, but it's silly.

Also, I think people submitting bugs / improvements would be a lot more encouraged if things like this were handled dead on. Why close an improvement suggestion, when it's a valid improvement? Anyone coding in OO would expect to be able to override Dictionary.add(). Leaving this closed is just setting it up for a repeat.

I'll help fix Dictionary. I'll leave the ticket closed out of respect, but I strongly feel it should be open.

Note: See TracTickets for help on using tickets.