Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6502] MobileWeb: Ti.App.Properties - setting a property to null causes execution failure

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-12-13T16:01:20.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-50, Release 1.8.0.1, Release 2.0.0
ComponentsMobileWeb
Labelsn/a
ReporterAnthony Decena
AssigneeAnthony Decena
Created2011-12-07T11:56:30.000+0000
Updated2017-03-03T22:52:33.000+0000

Description

If you try and set a property to null rather than using the removeProperty() method, the script execution stops.
Titanium.App.Properties.setString('String',null);
Titanium.API.info("String has been set to null " + Titanium.App.Properties.getString('String'));
The second line above will not execute.

Attachments

FileDateSize
app.js2011-12-10T13:29:32.000+00001373

Comments

  1. Chris Barber 2011-12-08

    Yeah, this is pretty easy to fix. Just need to do something like:
       api.setString = function(prop, val){
       	_setProp(prop, val, function(val){
       		return ""+(val||"");
       	});
       };
       
    If val is null or undefined, it'll get set to "". If it's a number, boolean, object, or array, it'll properly be converted to a string. Plus it saves a bunch of precious bytes!
  2. Chris Barber 2011-12-08

    OK, I stand corrected. We MUST support null values to get/setString().
       api.setString = function(prop, val){
       	_setProp(prop, val, function(val){
       		return val !== null ? ""+val : null;
       	});
       };
       
  3. Anthony Decena 2011-12-10

    The second Properties.getString line should execute correctly with the changes from this pull request: https://github.com/appcelerator/titanium_mobile/pull/909
  4. Lee Morris 2017-03-03

    Closing ticket.

JSON Source