Sencha Touch version tested:
  • Sencha Touch 2.1 - Build date: 2012-11-05 22:31:29 (08c91901ae8449841ff23e5d3fb404d6128d3b0b)
Browser versions tested against:
  • Chrome 24.0.1312.57
  • Safari iOS 6
Description:
  • Our application was created with Sencha Touch 2.0.1, and is in production already. In multiple parts, I used the "data" property of the objects to store information I needed for later retrieval, in some cases that information is a number or a boolean. After updating our application to use Sencha Touch 2.1, I discovered, to my surprise, that the framework now replaces the data properties that are considered [false] with an empty object. This silent change broke several parts of our application, and I really don't see why Sencha would try to parse my "data" values anyhow, since it's supposed to store values chosen by the developer.
Steps to reproduce the problem:
  • Create an element with the sample I appended below.
The result that was expected:
  • The values in the data properties should not be modified by the framework
The result that occurs instead:
  • Values considered "false" are being converted to empty Objects ({})
Test Case:
Code:
(...)
    {
        xtype: 'segmentedbutton',
        allowDepress: false,
        items: [
            {
                text: 'Option 1',
                data: 0, // this will become an empty Object ({})
                pressed: true,
                flex: 1
            },
            {
                data: 1,
                text: 'Option 2',
                flex: 1
            }
        ]
    },
(...)




(...)
    {
        xtype: 'segmentedbutton',
        allowDepress: false,
        items: [
            {
                text: 'Option 1',
                data: true,
                pressed: true,
                flex: 1
            },
            {
                data: false, // this will become an empty Object ({})
                text: 'Option 2',
                flex: 1
            }
        ]
    },
(...)
Possible fix:
  • Somewhere in the framework probably there's a code piece like "if (!data) data = {}", and this should not exist. If it HAS to exist somehow for the framework to work, create another private property, don't use a property publicly available to the developers and change its value silently without letting us know about it.