Chromium Code Reviews| Index: lib/src/html5_utils.dart |
| diff --git a/lib/src/html5_utils.dart b/lib/src/html5_utils.dart |
| index bb8903e90557418662381ea891a56c4218c07b78..d31a7635003ca206055ce337d4a2ec303c270610 100644 |
| --- a/lib/src/html5_utils.dart |
| +++ b/lib/src/html5_utils.dart |
| @@ -129,3 +129,167 @@ const htmlElementNames = const { |
| 'video': 'VideoElement', |
| 'wbr': 'Element', |
| }; |
| + |
| +/** A constant used as a special value in [htmlAttributeTags]. */ |
| +const allHtmlElements = const ['*']; |
|
Siggi Cherem (dart-lang)
2012/10/27 00:46:45
nit: => ALL_HTML_ELEMENTS?
or are we leaning towa
Jennifer Messerly
2012/10/30 06:08:45
IMO, we should not use CAPS.
It does not really m
|
| + |
| +// TODO(jmesserly): it'd be much better to use compile time mirrors on the |
| +// HTML library to build this list. |
| +// TODO(jmesserly): there are some odd cases, like "border" on img. It is |
| +// not listed as an HTML attribute but it's supported by the DOM IDL. Do we |
| +// need any special handling for those? |
| +/** |
| + * For each HTML attributes, maps to a list of tags that support it. |
| + * If the value is equal to [allHtmlElements] it implies that it is supported |
| + * by all elements. Source: |
| + * <http://dev.w3.org/html5/spec/section-index.html#attributes-1> |
| + * |
| + * Be sure to use [elementFieldRenames] to see if the attribute has been |
| + * renamed. |
|
Siggi Cherem (dart-lang)
2012/10/27 00:46:45
... in 'dart:html'?
|
| + * |
| + * Note that 'command', 'data', 'dialog', and 'time' tags were removed, because |
| + * the corresponding element types do not exist. See [htmlElementNames]. |
| + * |
| + * Also removed are attributes that don't have DOM fields (yet?): accesskey, |
| + * class, contextmenu, manifest, seamless, typemustmatch. |
| + * |
| + * Also these attriubtes have no setter: style, form, list. |
| + * |
| + * Finally a few other things that are missing: |
| + * - 'type' on MenuElement and AreaElement. |
| + * - 'crossorigin' on MediaElement. |
| + * - 'media' on AreaElement and AnchorElement. |
| + * - 'hreflang' on AreaElement. |
| + * - 'rel' on AreaElement. |
| + * - 'label' on MenuElement. |
| + * - 'charset' on MetaElement. |
| + */ |
| +const htmlAttributeTags = const <List<String>>{ |
| + 'accept': const ['input'], |
| + 'accept-charset': const ['form'], |
| + 'action': const ['form'], |
| + 'alt': const ['area', 'img', 'input'], |
| + 'async': const ['script'], |
| + 'autocomplete': const ['form', 'input'], |
| + 'autofocus': const ['button', 'input', 'keygen', 'select', 'textarea'], |
| + 'autoplay': const ['audio', 'video'], |
| + 'border': const ['table'], |
| + 'challenge': const ['keygen'], |
| + 'charset': const ['script'], |
| + 'checked': const ['input'], |
| + 'cite': const ['blockquote', 'del', 'ins', 'q'], |
| + 'cols': const ['textarea'], |
| + 'colspan': const ['td', 'th'], |
| + 'content': const ['meta'], |
| + 'contenteditable': allHtmlElements, |
| + 'controls': const ['audio', 'video'], |
| + 'coords': const ['area'], |
| + 'crossorigin': const ['img'], |
| + 'datetime': const ['del', 'ins'], |
| + 'default': const ['track'], |
| + 'defer': const ['script'], |
| + 'dir': allHtmlElements, |
| + // TODO(jmesserly): CL out to add this back. |
| + // 'dirname': const ['input', 'textarea'], |
| + 'disabled': const ['button', 'fieldset', 'input', 'keygen', 'optgroup', 'option', 'select', 'textarea'], |
|
Siggi Cherem (dart-lang)
2012/10/27 00:46:45
80 col? (here & below)
|
| + 'draggable': allHtmlElements, |
| + 'dropzone': allHtmlElements, |
| + 'enctype': const ['form'], |
| + 'for': const ['label', 'output'], |
| + 'formaction': const ['button', 'input'], |
| + 'formenctype': const ['button', 'input'], |
| + 'formmethod': const ['button', 'input'], |
| + 'formnovalidate': const ['button', 'input'], |
| + 'formtarget': const ['button', 'input'], |
| + 'headers': const ['td', 'th'], |
| + 'height': const ['canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video'], |
| + 'hidden': allHtmlElements, |
| + 'high': const ['meter'], |
| + 'href': const ['a', 'area', 'link', 'base'], |
| + 'hreflang': const ['a', 'link'], |
| + 'http-equiv': const ['meta'], |
| + 'id': allHtmlElements, |
| + 'ismap': const ['img'], |
| + 'keytype': const ['keygen'], |
| + 'kind': const ['track'], |
| + 'label': const ['optgroup', 'option', 'track'], |
| + 'lang': allHtmlElements, |
| + 'loop': const ['audio', 'video'], |
| + 'low': const ['meter'], |
| + 'max': const ['input', 'meter', 'progress'], |
| + 'maxlength': const ['input', 'textarea'], |
| + 'media': const ['link', 'source', 'style'], |
| + 'mediagroup': const ['audio', 'video'], |
| + 'method': const ['form'], |
| + 'min': const ['input', 'meter'], |
| + 'multiple': const ['input', 'select'], |
| + 'muted': const ['audio', 'video'], |
| + 'name': const ['button', 'fieldset', 'input', 'keygen', 'output', 'select', 'textarea', 'form', 'iframe', 'object', 'map', 'meta', 'param'], |
| + 'novalidate': const ['form'], |
| + 'open': const ['details'], |
| + 'optimum': const ['meter'], |
| + 'pattern': const ['input'], |
| + 'placeholder': const ['input', 'textarea'], |
| + 'poster': const ['video'], |
| + 'preload': const ['audio', 'video'], |
| + 'readonly': const ['input', 'textarea'], |
| + 'rel': const ['a', 'link'], |
| + 'required': const ['input', 'select', 'textarea'], |
| + 'reversed': const ['ol'], |
| + 'rows': const ['textarea'], |
| + 'rowspan': const ['td', 'th'], |
| + 'sandbox': const ['iframe'], |
| + 'spellcheck': allHtmlElements, |
| + 'scope': const ['th'], |
| + 'scoped': const ['style'], |
| + 'selected': const ['option'], |
| + 'shape': const ['area'], |
| + 'size': const ['input', 'select'], |
| + 'sizes': const ['link'], |
| + 'span': const ['col', 'colgroup'], |
| + 'src': const ['audio', 'embed', 'iframe', 'img', 'input', 'script', 'source', 'track', 'video'], |
| + 'srcdoc': const ['iframe'], |
| + 'srclang': const ['track'], |
| + 'start': const ['ol'], |
| + 'step': const ['input'], |
| + 'tabindex': allHtmlElements, |
| + 'target': const ['a', 'area', 'base', 'form'], |
| + 'title': allHtmlElements, |
| + 'translate': allHtmlElements, |
| + 'type': const ['a', 'link', 'button', 'embed', 'object', 'script', 'source', 'style', 'input'], |
| + 'usemap': const ['img', 'object'], |
| + 'value': const ['button', 'option', 'input', 'li', 'meter', 'progress', 'param'], |
| + 'width': const ['canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video'], |
| + 'wrap': const ['textarea'], |
| +}; |
| + |
| +/** |
| + * Gets the DOM field name in `dart:html` for an HTML attribute. |
| + * Generally this means making it camel case. If the field is not in this table, |
| + * that means the name is unchanged from HTML. |
| + */ |
| +const elementFieldRenames = const { |
|
Siggi Cherem (dart-lang)
2012/10/27 00:46:45
maybe rename to also use ALL_CAPS
|
| + 'accept-charset': 'acceptCharset', |
| + 'colspan': 'colSpan', |
| + 'contenteditable': 'contentEditable', |
| + 'contextmenu': 'contextMenu', |
| + 'crossorigin': 'crossOrigin', |
| + 'datetime': 'dateTime', |
| + 'default': 'defaultValue', |
| + 'dropzone': 'webkitdropzone', // Yuck. http://dartbug.com/4550 |
| + 'for': 'htmlFor', |
| + 'formaction': 'formAction', |
| + 'formenctype': 'formEnctype', |
| + 'formmethod': 'formMethod', |
| + 'formnovalidate': 'formNoValidate', |
| + 'formtarget': 'formTarget', |
| + 'http-equiv': 'httpEquiv', |
| + 'ismap': 'isMap', |
| + 'maxlength': 'maxLength', |
| + 'mediagroup': 'mediaGroup', |
| + 'novalidate': 'noValidate', |
| + 'readonly': 'readOnly', |
| + 'rowspan': 'rowSpan', |
| + 'tabindex': 'tabIndex', |
| + 'usemap': 'useMap' |
| +}; |