Success! Looks like we've fixed this one. According to our records the fix was applied for
SDKTOOLS-946
in
5.0.3.
-
Sencha Premium Member
callSuper works in develoment but not in production
Ext version tested:
- Ext 5.0.0
- Ext 5.0.1
- Ext 5.0.2.1432
Sencha Cmd version tested:
Steps to reproduce the problem:
Create a default application.
- In document root mkdir ext5
- sencha -sdk /path/to/ext generate app Test my/test
- In my/test/app/view create files Good.js
Code:
Ext.define('Test.view.Good', {
method: function () {
console.log('Good');
}
});
and Bad.js
Code:
Ext.define('Test.view.Bad', {
extend : 'Test.view.Good',
method: function () {
console.log('Bad');
// ... logic but with a bug ...
this.callParent();
}
});
- In my/test/overrides create folder view and in it file Bad.js
Code:
Ext.define('Test.overrides.view.Bad', {
override: 'Test.view.Bad',
method: function () {
console.log('Fixed');
// ... logic but with bug fixed ...
this.callSuper();
}
});
- In my/test/app/view/main/MainController.js modify onClickButton
Code:
onClickButton: function () {
Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
var my = Ext.create('Test.view.Bad');
my.method();
},
- sencha app watch
- sencha app build production
The result that was expected:
Browser pointed to localhost/ext5/my/test/index.html. Click Button. In console
Browser pointed to localhost/ext5/my/test/build/production/Test/index.html. Click Button. In console
The result that occurs instead:
Browser pointed to localhost/ext5/my/test/index.html. Click Button. In console
Browser pointed to localhost/ext5/my/test/build/production/Test/index.html. Click Button. In console
-
Thanks for the bug report. It looks like this is fixed for the upcoming Cmd 5.0.3
-
This is concerning, since use callSuper in a few Ext overrides ourselves.
Does it always call the immediate base class rather than the original one, or does it need a specific set of conditions to apply?
Any workaround for it?
Cheers,
Westy
-
You should be able to disable that optimization locally like so:
Code:
foo: function() {
// @noOptimize.callParent
this.callSuper();
//...
},
The //@noOptimize.callParent directive above disables that piece of the optimizer for just that next line.
To disable entirely, you can add the following to app.json:
Code:
"output": {
//...
"js": {
"optimize": {
"callParent": false
}
}
}
Even though "callParent" is the name of the optimization, it optimizes both callParent and callSuper calls.
Don Griffin
"Use the source, Luke!"