W3C home > Mailing lists > Public > public-html@w3.org > June 2007

Re: Conceptual modelling of attributes

From: Anne van Kesteren <annevk@opera.com>
Date: Mon, 11 Jun 2007 19:28:23 +0200
To: "Henrik Dvergsdal" <henrik.dvergsdal@hibo.no>, "HTML WG" <public-html@w3.org>
Message-ID: <op.ttrphlpu64w2qv@annevk-t60.oslo.opera.com>

On Mon, 11 Jun 2007 14:56:27 +0200, Henrik Dvergsdal  
<henrik.dvergsdal@hibo.no> wrote:
> According to this text, the attribute seems to have states with  
> associated get and set mappings. The contenteditable attribute seems to  
> be modelled as follows:
>
> States: true, false, unset
> Default state: unset (?)
> Set mappings: "true"=>true, ""=>true, other values=>false  (case  
> independent)
> Get mappings: true=>"true", false=>"false", unset=>"inherit"

A user agent has to treat it as such. Note that the text says nothing  
about changing the value of the _content_ attribute in any way. So that  
part is compatible.


There is one problem with the text though. That is that when the attribute  
has an invalid value it should be treated the same as if the attribute was  
not set at all. This means for instance that:

   <div contenteditable>
     <div contenteditable=foobar>
       This will be editable.

I think I already made a comment regarding that on the WHATWG mailing  
list...


> [...]
>
> So my question is: What should be the conceptual model of element  
> attributes?

Depends on the attribute. Some attributes are boolean attributes. For  
instance:

   <input type=checkbox checked>

checked= is the boolean attribute here. If the attribute is present,  
regardless of its value, its DOM attribute will return true (even for  
checked=false). If the attribute is not present the checked DOM attribute  
will return false. Setting the DOM attribute will either set or unset the  
content attribute, etc. Then you have attributes like contenteditable=  
which take an enumerated set of values and there's a whole bunch of  
attributes that take URLs. I recommend you read

   http://www.whatwg.org/specs/web-apps/current-work/#terminology
   http://www.whatwg.org/specs/web-apps/current-work/#reflecting

and maybe

   http://www.whatwg.org/specs/web-apps/current-work/#common1


-- 
Anne van Kesteren
<http://annevankesteren.nl/>
<http://www.opera.com/>
Received on Monday, 11 June 2007 17:28:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:00 GMT