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  

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

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

   <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


and maybe


Anne van Kesteren
Received on Monday, 11 June 2007 17:28:32 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:22 UTC