Tuesday, 28 May 2013

dojo.mixin not working as expected

dojo.mixin not working as expected

I think I am using dojo.mixin not as required...
I have the following code:
dojo.declare("A",null,{
    _configuration: {},
    constructor: function(configuration)
    {
        if(this._configuration.something === 2)
        {
            // we should never come here; the constructor is only called on a new instance which should still have an empty _somethingPrivate
            // because the class declaration says so
            console.log("why does this happen?");
        }

        // merge empty configuration
        dojo.mixin(this._configuration, configuration);
    }
});

var myInstance = new A({ something: 2 });
var myInstance = new A({});
As far as I understand, you can use dojo.mixin to merge objects. I try to merge a default configuration object with given parameters (in an object), but the console output is "why does this happen?" so the parameters from previous object are merged into a new object.
Can anyone shed some light on this?
By the way: dojo version 1.6 (we cannot upgrade yet)

No comments:

Post a Comment