-
1 Dec 2012 3:37 AM #1
[2.1] Class creation inconsistency
[2.1] Class creation inconsistency
Test case:
So, we have two classes- 'component' and my anonymous class.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'});
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.
-
1 Dec 2012 7:52 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,704
- Vote Rating
- 435
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
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Dec 2012 12:03 PM #3
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.
-
2 Dec 2012 4:59 AM #4
More concise sample,web browser:
why it's 'true'? Why first value is 'undefined' and second is 'test'.Code:(new Ext.Class()).create({ action: 'test' }).action !== Ext.widget('component', { action: 'test' }).action
And native ios build has both values 'undefined'.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote