A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

User:Matthew Raymond/dataentry element: Difference between revisions

From WHATWG Wiki
Jump to navigation Jump to search
m (Replacing page with 'The')
m (Reverted edits by Rs1Xew (Talk); changed back to last version by Matthew Raymond)
Line 1: Line 1:
The
The <dataentry> element is just like <input>, with three exceptions:
 
* It doesn't have the depreciated attributes.
* It has no |alt| attribute, but instead contains alternative contents as child nodes for legacy support.
* It requires a closing tag ("</dataentry>").
* It must contain at least one form control. If </dataentry> has a defined |name| attribute, then it must contain at least one form control with a defined |name| attribute.
 
==Examples==
 
Here's a simple example for the three <select> scenario:
 
<dataentry type="date" id="d1" name="d1" value="2005-02-09">
  <select name="d1_day"><!-- Options --></select> /
  <select name="d1_month"><!-- Options --></select> /
  <select name="d1_year"><!-- Options --></select>
</dataentry>
 
Here's an example for users of jscalendar:
 
<dataentry type="date" id="sel1_WF2" name="date1">
  <input type="text" id="sel1" name="date1" size="30">
  <input type="reset" value=" ... " onclick="return showCalendar('sel1', '%Y-%m-%d');">
  YYYY-MM-DD
</dataentry>
 
==Pros==
 
# The <dataentry> element can allow for a far greater range of legacy fallback than <input>.
# Because the |type| is defined in an attribute, <dataentry> can be used for input types in later specifications, or for vendor-specific input types.
# The element is designed in both semantics and structure to encourages the use of <input> in simple cases where legacy fallback needs are minimal.
# The element is designed only to prevent the presentation of its child elements. It does not require user agents to delete contents from the DOM or suppress Javascript execution.
# Because it has the same attributes as <input>, there's nothing new to learn except the inclusion of fallback content.
 
==Cons==
 
# The size of a form's elements collection in Javascript may differ between user agents.
# There may be legacy Javascript issues that cause script failure when generating unrecognized elements.
# When creating an <dataentry> element, you should be able to test for the correct element type by checking to see if it has a .type property, but I can't be 100% certain.
# Some unneeded Javascript overhead on WF2 clients.
# CSS styling for <dataentry> can't be done directly because user agents that support unrecognized elements may use the styling instead of ignoring the <dataentry> as intended.
 
==Solutions For Cons==
 
# A simple method could be added to the DOM that would set whether a form control is include in the .elements collection. A function could then be run when the page loads to hide the <dataentry> elements from the collection.
# This is a general issue affecting all new elements we introduce.
# May not be an issue, but I'd like to hear from an expert.
# Ian seems to feel this is a non-issue, so I won't argue with him.
# I'm considering a pseudo-class (":controltype()" or ":dom(attr, val)"?) that should allow a web author to style <dataentry type="controltype"> when the control type is supported. I'm still working on this concept, though, and I'm wondering if a more general and more powerful pseudo-class can't be developed.
__NOTOC__

Revision as of 11:53, 12 April 2007

The <dataentry> element is just like <input>, with three exceptions:

  • It doesn't have the depreciated attributes.
  • It has no |alt| attribute, but instead contains alternative contents as child nodes for legacy support.
  • It requires a closing tag ("</dataentry>").
  • It must contain at least one form control. If </dataentry> has a defined |name| attribute, then it must contain at least one form control with a defined |name| attribute.

Examples

Here's a simple example for the three <select> scenario:

<dataentry type="date" id="d1" name="d1" value="2005-02-09">
 <select name="d1_day"><!-- Options --></select> /
 <select name="d1_month"><!-- Options --></select> /
 <select name="d1_year"><!-- Options --></select>
</dataentry>

Here's an example for users of jscalendar:

<dataentry type="date" id="sel1_WF2" name="date1">
 <input type="text" id="sel1" name="date1" size="30">
 <input type="reset" value=" ... " onclick="return showCalendar('sel1', '%Y-%m-%d');">
 YYYY-MM-DD
</dataentry>

Pros

  1. The <dataentry> element can allow for a far greater range of legacy fallback than <input>.
  2. Because the |type| is defined in an attribute, <dataentry> can be used for input types in later specifications, or for vendor-specific input types.
  3. The element is designed in both semantics and structure to encourages the use of <input> in simple cases where legacy fallback needs are minimal.
  4. The element is designed only to prevent the presentation of its child elements. It does not require user agents to delete contents from the DOM or suppress Javascript execution.
  5. Because it has the same attributes as <input>, there's nothing new to learn except the inclusion of fallback content.

Cons

  1. The size of a form's elements collection in Javascript may differ between user agents.
  2. There may be legacy Javascript issues that cause script failure when generating unrecognized elements.
  3. When creating an <dataentry> element, you should be able to test for the correct element type by checking to see if it has a .type property, but I can't be 100% certain.
  4. Some unneeded Javascript overhead on WF2 clients.
  5. CSS styling for <dataentry> can't be done directly because user agents that support unrecognized elements may use the styling instead of ignoring the <dataentry> as intended.

Solutions For Cons

  1. A simple method could be added to the DOM that would set whether a form control is include in the .elements collection. A function could then be run when the page loads to hide the <dataentry> elements from the collection.
  2. This is a general issue affecting all new elements we introduce.
  3. May not be an issue, but I'd like to hear from an expert.
  4. Ian seems to feel this is a non-issue, so I won't argue with him.
  5. I'm considering a pseudo-class (":controltype()" or ":dom(attr, val)"?) that should allow a web author to style <dataentry type="controltype"> when the control type is supported. I'm still working on this concept, though, and I'm wondering if a more general and more powerful pseudo-class can't be developed.