Titanium JIRA Archive
Alloy (ALOY)

[ALOY-822] Add support for unsetting properties in TSS via 'undefined'

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-05-28T19:57:35.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.4.0, 2014 Sprint 02
ComponentsStyling
Labelsalloy, qe-testadded, tss
ReporterMauro Parra-Miranda
AssigneeTony Lukasavage
Created2013-09-03T11:24:46.000+0000
Updated2014-05-29T18:03:47.000+0000

Description

I would like to be able to *un*set properties via TSS (and XML).

Use case

I want all windows to be heavyweight by default so my app.tss has:
"Window": {
  modal: false
}
But I have one widget which absolutely needs its window to be lightweight. Right now there is no way to do this. I can set modal to a different value like true, but even setting it to null won't make the window lightweight again. I tried setting modal to undefined but it throws a syntax error:
Expected "Alloy", "L", "Ti", "Titanium", "WPATH", "[", "false", "null", "true", "{", comment, end of line, number, string or whitespace but "u" found.

Proposed solution

My suggestion is to accept undefined as a valid value, but instead of actually setting it, use it to trigger removing the property. That way, for that specific window I can set modal to undefined which would remove that property from the dictionary passed to Ti.UI.createWindow.

Comments

  1. Fokke Zandbergen 2013-12-03

    When will this be discussed in triage?
  2. Tony Lukasavage 2014-01-17

    For this ticket we will be making undefined usable in TSS, but the rest is outside the scope of ALOY. I created a similar ticket, TIMOB-16225, as "unsetting" properties needs to be handled at the platform level. Simple passing undefined to proxy properties actually has specific behavior in some cases, so Alloy can't just assume that it means it should remove it.
  3. Fokke Zandbergen 2014-01-17

    Thx Tony, know about that ticket and see the difference.
  4. Tony Lukasavage 2014-01-21

    PR: https://github.com/appcelerator/alloy/pull/305 test app: https://github.com/appcelerator/alloy/tree/master/test/apps/testing/ALOY-822 Functional test consists of simply making sure that the given test app will compile without error. Prior to this fix, it would abort with the error mentioned in the description of this ticket. Additionally you can confirm that the generated controller code creates a void 0 entry where the undefined should be (as uglify-js minifies it).

JSON Source