Re: Empty attribute syntax and the DOM and CSS

Daniel Schattenkirchner wrote:
> 
> I wonder how empty attributes are represented in the DOM and how they 
> should work with CSS. Take a look at the example code:
> 
> <!doctype html>
> <html>
> <body>
> <p><input type="submit" disabled></p>
> </body>
> </html>
> ...
> 
> It's an unimportant edge case, but if I didn't miss the relevant parts 
> in the draft, it is undefined how <element disabled /> should be 
> represented.

It is defined.  In the tokenisation section of the parsing algorithm, 
the spec states this about creating a new attribute:

| Start a new attribute in the current tag token. Set that attribute's
| name to the lowercase version of the current input character (add
| 0x0020 to the character's code point), and its value to the empty
| string. Switch to the attribute name state.

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

Since the value never gets changed from the empty string if there it 
never reaches either of the attribute value states, the value remains as 
the empty string.  Therefore, <input disabled> is identical in meaning 
to <input disabled="">.  The implementations that treat those 
differently are broken.

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Sunday, 22 June 2008 12:05:13 UTC