Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2009
    Location
    Hamburg, Germany
    Posts
    4
    Vote Rating
    0
    Bartholomew is on a distinguished road

      0  

    Default Mixin referenced in parent class

    Mixin referenced in parent class


    I'm not to shure if this is really a bug, but when extending a class with defined mixins and creating an instance of the parent class after that, the mixins of the child class is also referenced in the parent class.
    The problem is, that I have to create multiple classes extended from the same parent with multiple mixins with the same reference key name but different classes. When doing so, the mixins with the same key name of all children map the the same (latest) class. I use Ext JS 4.0.2.

    Example:
    Code:
    Ext.define('Test', {
        extend: 'Ext.panel.Panel',
        mixins: {
            test: 'Ext.button.Button'
        }
    });
    Ext.define('Test2', {
        extend: 'Ext.panel.Panel',
        mixins: {
            test: 'Ext.window.Window'
        }
    });
    
    // mixin.test will be Ext.window.Window for all three classes (Panel, Test, Test2)
    Thanks for your help.

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    I can confirm this behavior and added a more explicit test case.

    REQUIRED INFORMATION


    Ext version tested:
    • 4.0.2a

    Browser versions tested against:
    • Chrome 12

    Description:
    • Mixins added to a class will appear in the mixins 'collection' of its parent-class and other classes that inherit from the same parent-class.
    • While this is already rather strange and probably unintended, it will cause problems when two of these classes use the same mixin name for different Mixin classes.

    Steps to reproduce the problem:
    • Add a mixin M1 to a class A by name 'mymixin'.
    • Add a different mixin M2 to a class B by the same name 'mymixin'.
    • access the mixins collection of class A via 'this.mixins.mymixin.someProperty'

    The result that was expected:
    • result is the value of the property in Mixin M1

    The result that occurs instead:
    • result is the value of the property in Mixin M2

    Test Case:

    Code:
    Ext.define('MixinA', {
    	property : 'MixinA'
    });
    Ext.define('MixinB', {
    	property : 'MixinB'
    });
    Ext.define('MixinC', {
    	property : 'MixinC'
    });
    
    Ext.define('Test1', {
    	extend: 'Ext.panel.Panel',
    	mixins: {
    		test: 'MixinA'
    	}
    });
    Ext.define('Test2', {
    	extend: 'Ext.panel.Panel',
    	mixins: {
    		test: 'MixinB',
    		othermixin: 'MixinC'
    	}
    });
    
    Ext.onReady(function() {
    	var test1 = Ext.create('Test1');
    	var test2 = Ext.create('Test2')
    
    	function describe(obj) {
    		console.log('obj.$className: ' + obj.$className);
    		console.log('obj.property: ' + obj.property);
    		console.log('obj.mixins.test.$className: ' + obj.mixins.test.$className);
    		console.log('obj.mixins.test.property: ' + obj.mixins.test.property);
    		console.log('obj.mixins.othermixin.property: ' + obj.mixins.othermixin.property);
    		console.log('----');
    	}
    	describe(test1);
    	describe(test2);
    	describe(Ext.create('Ext.panel.Panel'));
    });
    output

    Code:
    obj.$className: Test1
    obj.property: MixinA
    obj.mixins.test.$className: MixinB
    obj.mixins.test.property: MixinB
    obj.mixins.othermixin.property: MixinC
    ----
    obj.$className: Test2
    obj.property: MixinB
    obj.mixins.test.$className: MixinB
    obj.mixins.test.property: MixinB
    obj.mixins.othermixin.property: MixinC
    ----
    obj.$className: Ext.panel.Panel
    obj.property: undefined
    obj.mixins.test.$className: MixinB
    obj.mixins.test.property: MixinB
    obj.mixins.othermixin.property: MixinC
    ----

  3. #3
    Sencha - Ext JS Dev Team
    Join Date
    Jun 2011
    Location
    Boston
    Posts
    81
    Vote Rating
    4
    germanicus is on a distinguished road

      0  

    Default


    Thanks for the test case. I've verified that this has been fixed in 4.1, and I requested to have it merged into 4.0.6.

  4. #4
    Ext JS Premium Member n3rd's Avatar
    Join Date
    Nov 2007
    Location
    Munich
    Posts
    72
    Vote Rating
    0
    n3rd is on a distinguished road

      0  

    Default


    I second that. Please make sure it gets merged back to 4.0.6. Thanks a lot.

  5. #5
    Sencha - Ext JS Dev Team
    Join Date
    Jun 2011
    Location
    Boston
    Posts
    81
    Vote Rating
    4
    germanicus is on a distinguished road

      0  

    Default


    Just confirmed that this will be merged into 4.0.6.