W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2011

[whatwg] Microdata - Handling the case where a string is upgraded to an object

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 14 Jul 2011 11:49:44 -0700
Message-ID: <CAAWBYDBLrj=c6p8Y93bLBHGv5pYCbc-2Q18oF1iuCpnDY23XPA@mail.gmail.com>
Some IRC discussion this morning concerned the scenario where an API
starts by exposing a property as a string, but later wants to change
it to be a complex object.

This appears to be a reasonably common scenario.  For example, a
vocabulary with a "name" property may start with it being a string,
and then later change to an object exposing "firstname"/"lastname"/etc
properties.  A vocabulary for a music library may start by having
"track" as a string, then later expanding it to expose the track
title, the individual artist, the running time, etc.

In a very similar vein, the CSSOM is currently defined to always
return property values as strings.  We want to instead return complex
objects that expose useful information and interfaces specialized on
the value's type, however.  For compat reasons, we have to use an
entirely different accessor in order to expose this type of thing.

It seems that this may be a useful problem to solve in Microdata.  We
can expose either an attribute or a privileged property name for the
object's "name"/"title"/"string representation".  Then, when using the
.items accessor, objects can be returned with a custom .toString that
returns that value, so they can be used as strings in legacy code.


Received on Thursday, 14 July 2011 11:49:44 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:34 UTC