Titanium JIRA Archive
Alloy (ALOY)

[ALOY-392] optimizer.js only optimizes platform conditionals if Ti.Platform is on left hand side

GitHub Issuen/a
TypeBug
PriorityMedium
StatusResolved
ResolutionFixed
Resolution Date2012-11-15T16:06:23.000+0000
Affected Version/sAlloy 0.3.1
Fix Version/sAlloy 0.3.2, 2012 Sprint 23
ComponentsXML
Labelsn/a
ReporterTony Lukasavage
AssigneeUnknown
Created2012-11-15T14:39:21.000+0000
Updated2018-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;"]

Comments

  1. Tony Lukasavage 2012-11-15

    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

JSON Source