[whatwg] [WA1] Attribute-based selection system

Matthew Raymond mattraymond at earthlink.net
Sat Jun 25 10:49:02 PDT 2005


    This is a specification of my selection system that I discussed over 
several previous messages. A few modifications have been made since 
then, so reference this rather than previous messages.

*** |selection| attribute ***

selection = single | multiple [allowzero] [auto] [tree]

    The |selection| attribute specifies that the element is a container 
for selectable content. Possible values:

  * single - Mutually exclusive selection. Can't be used with "multiple".

  * multiple - Multiple item selection. Cannot be used with "single".

  * tree - Makes the current selection part of the parent selection.

  * allowzero - Allows for the selection of zero items.

  * auto - Default value for an immediate child |selectable| attribute 
is "true".


*** |selectable| attribute ***

selectable = true | false

    The |selectable| attribute determines whether or not an element 
within a selection container is selectable. If the element does not have 
an ancestor with a valid |selection| attribute value set, then the 
|selectable| attribute is semantically meaningless. Possible values:

  * true - The element can be selected.

  * false - The element cannot be selected.

    Unless the immediate parent element is a selection container with 
the value "auto" specified, the default is always false. If an element 
has |selectable| set to "true", then the |selectable| attributes for all 
descendants that are not children of descendant selection container 
elements are semantically meaningless.


*** |selected| attribute ***

    The |selected| attribute now applies to all selectable elements in 
addition to the <option> element.


*** Examples ***

    The following is a table with only the first cell of each row 
selectable:

| <table selection="single">
|   <tr>
|     <td selectable="true" selected>Item 1</td>
|     <td> ...contents... </td>
|     <td> ...contents... </td>
|   </tr>
|   <tr>
|     <td selectable="true">Item 2</td>
|     <td> ...contents... </td>
|     <td> ...contents... </td>
|   </tr>
|   <tr>
|     <td selectable="true">Item 3</td>
|     <td> ...contents... </td>
|     <td> ...contents... </td>
|   </tr>
| </table>

    This is a multiple-selection list with the first item selected:

| <ul selection="multiple auto">
|   <li selected>Item 1</li>
|   <li>Item 2</li>
|   <li>Item 3</li>
| </ul>

    Below is a multiple-selection list-based tree where only the leaves 
are selectable:

| <ul selection="multiple auto">
|   <li selectable="false">
|     <p>Item 1</p>
|     <ul selection="multiple auto tree">
|       <li>Item 1</li>
|       <li>Item 2</li>
|       <li>Item 3</li>
|     </ul>
|   </li>
|   <li>Item 2</li>
|   <li>Item 3</li>
| </ul>

    Here is an example of a table where all rows but the header row are 
selectable:

| <table selection="single">
|   <tbody>
|     <tr>
|       [...header row...]
|     </tr>
|     <tr selectable="true" selected>
|       [...first row of block two data...]
|     </tr>
|     <tr selectable="true">
|       [...second row of block two data...]
|     </tr>
|     <tr selectable="true">
|       [...third row of block two data...]
|     </tr>
|   </tbody>
| </table>

    Here's a different version of the above example:

| <table>
|   <tbody selection="single auto">
|     <tr selectable="false">
|       [...header row...]
|     </tr>
|     <tr selected>
|       [...first row of block two data...]
|     </tr>
|     <tr>
|       [...second row of block two data...]
|     </tr>
|     <tr>
|       [...third row of block two data...]
|     </tr>
|   </tbody>
| </table>




More information about the whatwg mailing list