[ALOY-392] optimizer.js only optimizes platform conditionals if Ti.Platform is on left hand side
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2012-11-15T16:06:23.000+0000 |
Affected Version/s | Alloy 0.3.1 |
Fix Version/s | Alloy 0.3.2, 2012 Sprint 23 |
Components | XML |
Labels | n/a |
Reporter | Tony Lukasavage |
Assignee | Unknown |
Created | 2012-11-15T14:39:21.000+0000 |
Updated | 2018-03-07T22:25:44.000+0000 |
Description
Here's the failing test, as added to the unit testing for the optimizer:
// FAIL: Only works if Ti.Platform.* is on the left hand side (false negative)
["if ('<%= Ti_Platform_name %>' === Ti.Platform.osname) { var a = 1; } else { a = 2; }","var a=1;"]
optimizer.js code works regardless of which side of the comparison a Ti.Platform API is on. All tests pass, including about 20 new ones that are sure to test both sides of a comparison. This is a result of a major simplification of the optimizer.js code in combination with allowing uglifyjs to remove dead code. The commit(s) can be seen here: * refactored code: ** https://github.com/appcelerator/alloy/commit/bcaffef93fada754103f4e1b8927133bb41f250a ** https://github.com/appcelerator/alloy/commit/a2e3294d6ab695b9a2f44d229f969a7fd9933453