Problem description
Using Dynamic Styles classes, some properties of Picker objects are not returned correctly.
It might be related to the fix introduced for ALOY-1051 (and eventually in PR501 for ALOY-1144), as is not reproducible using Alloy 1.4.1 and 1.5.0-rc3, but is reproducible using Alloy versions 1.5.0-rc4 and 1.5.0-rc (or 1.5.0-dev).
Steps to reproduce
1. Run the attached sample code
2. Click on the 'Hello World' label and check console log
Result:
Ti.API.info(JSON.stringify($.createStyle({
classes:['test', "pickerClass"]
})));
should return:
{"type":1,"minDate":"2012-01-01T00:00:00.000Z","maxDate":"2014-05-01T19:00:00.000Z","value":"2014-04-15T19:00:00.000Z","classes":["test","pickerClass"]}
(and that is what is being returned using 1.4.1 and 1.5.0-rc3)
instead, using Alloy 1.5.0-rc or 1.5.0-rc4, it returns:
{"type":1,"minDate":{},"maxDate":{},"value":{},"classes":["test","pickerClass"]}
..
With RC4 the alert/info statements show: * the properly merged properties for the dynamic style based on the family & size classes * incompletely merged properties for the dynamic style based on the test & pickerClass classes * the properly merged properties for the dynamic style based on the test2 & viewClass classes
With RC3, the alert/info statements show: * incompletely merged properties for the dynamic style based on the family & size classes * the properly merged properties for the dynamic style based on the test & pickerClass classes * the properly merged properties for the dynamic style based on the test2 & viewClass classes[INFO] {"font":{"fontFamily":"AmericanTypewriter","fontSize":50},"duration":1000,"classes":["family","size"]} [INFO] {"type":1,"minDate":{},"maxDate":{},"value":{},"classes":["test","pickerClass"]} [INFO] {"type":1,"id":"pickerTest","value":"2014-04-15T16:00:00.000Z","horizontalWrap":true,"minDate":"2012-01-01T00:00:00.000Z","columns":[],"maxDate":"2014-05-01T16:00:00.000Z"} [INFO] {"backgroundColor":"blue","width":"90%","height":50,"bottom":0,"pippo":"tanto pippo test, 22343","classes":["test2","viewClass"]}The pickerClass class would generate JavaScript Date objects, which would be evaluated when the info/alert methods are run. The[INFO] {"font":{"fontSize":50},"duration":1000,"classes":["family","size"]} [INFO] {"type":1,"minDate":"2012-01-01T00:00:00.000Z","maxDate":"2014-05-01T16:00:00.000Z","value":"2014-04-15T16:00:00.000Z","classes":["test","pickerClass"]} [INFO] {"type":1,"id":"pickerTest","value":"2014-04-15T16:00:00.000Z","horizontalWrap":true,"minDate":"2012-01-01T00:00:00.000Z","columns":[],"maxDate":"2014-05-01T16:00:00.000Z"} [INFO] {"backgroundColor":"blue","width":"90%","height":50,"bottom":0,"pippo":"tanto pippo test, 22343","classes":["test2","viewClass"]}JSON.stringify()method returnsnullfor objects with methods, which would include those Date objects. This is most likely the reason for the different output.I think there *is* an issue with Date objects, which can be fixed by:
.. if (_.isDate(copy)) { clone = new Date(copy.valueOf()); // Recurse if we're merging plain objects or arrays } else if (deep && copy && ((_.isObject(copy) && typeof copy.apiName !== 'string') || (copy_is_array = _.isArray(copy)))) { ..Which can be fixed by my comment above yours.
PRs: 1_5_X -- https://github.com/appcelerator/alloy/pull/572 master -- https://github.com/appcelerator/alloy/pull/573 Functional tests: * Run the attached app & follow steps to reproduce. The app should output the expected values * Run the ALOY\-1051 test app. Clicking the label should alert the properly merged style values * Run the advanced/complex_styling app and all font styles should be properly merged and displayed
Merged PRs.
Merged PRs: Master: https://github.com/appcelerator/alloy/pull/575 1_5_X: https://github.com/appcelerator/alloy/pull/576
When I run the attached project now with alloy 1.5.0 -rc4 taken from : git://github.com/appcelerator/alloy.git#1_5_X I am able to see the following result:
Hence, able to see the expected results.[INFO] : {"font":{"fontFamily":"AmericanTypewriter","fontSize":50},"duration":1000,"classes":["family","size"]} [INFO] : {"type":1,"minDate":"2012-01-01T00:00:00.000Z","maxDate":"2014-05-01T04:00:00.000Z","value":"2014-04-15T04:00:00.000Z","classes":["test","pickerClass"]} [INFO] : {"type":1,"id":"pickerTest","value":"2014-04-15T04:00:00.000Z","horizontalWrap":true,"minDate":"2012-01-01T00:00:00.000Z","columns":[],"maxDate":"2014-05-01T04:00:00.000Z"} [INFO] : {"backgroundColor":"blue","width":"90%","height":50,"bottom":0,"pippo":"tanto pippo test, 22343","classes":["test2","viewClass"]}Verified fixed. TiSDK 3.4.0.v20140924140915 Appcelerator Studio 3.4.0.201409231834 CLI 3.4.0-rc4 Alloy 1.5.0-rc4 Xcode6 iPad mini & iPhone 5 (iOS 8) and Android Galaxy Nexus 4.3 Closing.
Added story points