Re: Contacts API -- pref

Andreas Gal wrote:
>> The spec stays silent on that. There's no special behavior attached to the pref attribute.
>
> I can see that the spec is silent on that. My point is it doesn't make sense for the spec to be silent on that.

I don't see why it matters for a read-only API. Robin clarified in some 
detail why the spec is silent on this. The underlying contacts source 
has a set of rules on how it allocates preferred values and the results 
of that constitute what is sent to a web page via this API. If an 
underlying contacts source allows for multiple preferred values then it 
will communicate all of those values with this flag set. In short, the 
spec does not assume to know if the underlying contacts source supports 
0, 1 or more preferred values for any given property and is not enforced 
at the API level.

Having said that, when we come to write-back we may encounter some 
issues as Robin also touched on in his response. That gives us the same 
issues as with any data validation required at the contact source on 
write-back to determine if the contact record received is valid for the 
contact source in question. During data validation if I've sent 5 
preferred objects but the contact source only allows 1 then the contact 
source will take steps to remedy that situation or spit the record back 
to the web page to fix.

>
>>> Also, I wonder if the simple order of appearance might be a sufficient way to specify preference (maybe users want a different display order and preference order?).
>> Currently all major browsers loop over the properties of an object in the order in which they were defined. Chrome does this as well, except for a couple cases [1]. So there's potential for fragmentation on this. ECMA stays silent on the subject of ordering in these cases. ECMA-262 section 12.6.4 "The for-in Statement" says: "[t]he mechanics and order of enumerating the properties [...] is not specified". Relying on that ordering seems impossible based on that.
>
> What is the harm in sorting properties consistently and moving 'pref'?

If you're talking about putting your preferred objects first then I'm 
not sure it's possible based on the inconsistency in JS implementations 
(and lack of guidance on sorting from ECMA).

If you're talking about sorting properties consistently in the spec then 
I don't see a problem with doing that. That was referred to in another 
email you sent.

Perhaps I've just misunderstood the question and you could elaborate.

>
> Andreas
>
>> [1] http://code.google.com/p/chromium/issues/detail?id=883
>>

Received on Thursday, 25 August 2011 15:37:17 UTC