Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    228
    Vote Rating
    4
    XASD is on a distinguished road

      0  

    Default [2.1] Class creation inconsistency

    [2.1] Class creation inconsistency


    Test case:
    Code:
    var d = (new Ext.Class({
                config: {
                    test: 'action'
                },
                constructor: function (config) {
                    this.initConfig(config);
                }
            })).create({action:'test'});
    
    var d1= Ext.widget('component', {action:'test'});
    So, we have two classes- 'component' and my anonymous class.
    Ext.define(null,{}) not working in sencha touch but in extjs work perfectly.
    I have created two instances of corresponding classes named 'd1' and 'd'.
    Now "interesting" behavior.
    1) d1.action=='test'
    but
    2) d.action==undefined

    framework classes is somehow differ?

    d1.config and d.config both contain 'action' property.
    But in 'component' case it also defined as instance property(chrome browser).

    That inconsistency is critical, because in case of native build (for ios), 'component' does not define instance property- same behavior as my custom class.
    But in chrome browser 'action" is visible as instance property!

    So,question is-what's correct behavior from javascript perspective regardless of browser details?
    Should 'action' (not config property!!!) be defined as instance property or be available only through 'config' object?
    What's definition of instance properties,not confusing with config properties? Does dynamic nature of javascript still intact?
    By the way, some_container.down('component[action]') still find instance I need,though 'action' is not visible as instance property in iOs=native case.Strange things happen...

    Thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This is not a bug. Sencha Touch makes full use of the config object where Ext JS never fully implemented throughout the framework.

    If a property is in the config object, the actual property that is created is a private one with '_' prefixed to it but you should use the generated getter method to retrieve it not access the property itself.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    228
    Vote Rating
    4
    XASD is on a distinguished road

      0  

    Default


    I'm not talking about config properties,but about simple properties defined at the time of class declaration or instance creation. 'action' is not defined as config property, and Ext.widget('component',{action:'test'}) not create "config" property nor initialize it.
    It's simple instance property,which is available as particular instance property,named 'action'.

    Thanks.

  4. #4
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    228
    Vote Rating
    4
    XASD is on a distinguished road

      0  

    Default


    More concise sample,web browser:
    Code:
    (new Ext.Class()).create({ action: 'test' }).action !== Ext.widget('component', { action: 'test' }).action
    why it's 'true'? Why first value is 'undefined' and second is 'test'.
    And native ios build has both values 'undefined'.

Thread Participants: 1