You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Peter (JIRA)" <ji...@apache.org> on 2013/09/17 04:17:53 UTC

[jira] [Created] (CB-4849) Inconsistent constructors for the Contact objects

Peter created CB-4849:
-------------------------

             Summary: Inconsistent constructors for the Contact objects
                 Key: CB-4849
                 URL: https://issues.apache.org/jira/browse/CB-4849
             Project: Apache Cordova
          Issue Type: Improvement
          Components: CordovaJS
    Affects Versions: 2.9.0
            Reporter: Peter
            Assignee: Andrew Grieve
            Priority: Minor


It is curious that the ContactField constructor ensures that members are converted to strings as per the documentation, but the other Contact constructors like ContactOrganization, ContactAddress do not follow the same code pattern. Is there some reason for the difference?

For example,

{code}
var ContactField = function(type, value, pref) {
    this.id = null;
    this.type = (type && type.toString()) || null;
    this.value = (value && value.toString()) || null;
    this.pref = (typeof pref != 'undefined' ? pref : false);
};
{code}

vs.

{code}
var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
    this.id = null;
    this.pref = (typeof pref != 'undefined' ? pref : false);
    this.type = type || null;
    this.formatted = formatted || null;
    this.streetAddress = streetAddress || null;
    this.locality = locality || null;
    this.region = region || null;
    this.postalCode = postalCode || null;
    this.country = country || null;
};
{code}

It means (for example) that user can create a ContactField for a phone numbers passing a value of 123456 and it will be coverted OK to '123456'. But if user passed numeric 1234 as a ContactAddress postalCode the assigned member will have the wrong type.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira