Re: Conceptual modelling of attributes

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 UTC