Chromium Code Reviews| Index: tools/dom/src/dart2js_CustomElementSupport.dart |
| diff --git a/tools/dom/src/dart2js_CustomElementSupport.dart b/tools/dom/src/dart2js_CustomElementSupport.dart |
| index 95c64b678f51a7821c8c6dffc510de769523f684..f801b8b607e3a5b4508cb4ee4b6e94b25a24f851 100644 |
| --- a/tools/dom/src/dart2js_CustomElementSupport.dart |
| +++ b/tools/dom/src/dart2js_CustomElementSupport.dart |
| @@ -18,6 +18,79 @@ _makeCreatedCallbackMethod() { |
| convertDartClosureToJS(_callCreated, 1)); |
| } |
| +const _typeNameToTag = const { |
| + 'HTMLAnchorElement': 'a', |
| + 'HTMLAppletElement': 'applet', |
| + 'HTMLAreaElement': 'area', |
| + 'HTMLAudioElement': 'audio', |
| + 'HTMLBRElement': 'br', |
| + 'HTMLBaseElement': 'base', |
| + 'HTMLBaseFontElement': 'basefont', |
| + 'HTMLBodyElement': 'body', |
| + 'HTMLButtonElement': 'button', |
| + 'HTMLCanvasElement': 'canvas', |
| + 'HTMLDListElement': 'dl', |
| + 'HTMLDataListElement': 'datalist', |
| + 'HTMLDirectoryElement': 'dir', |
| + 'HTMLDivElement': 'div', |
| + 'HTMLEmbedElement': 'embed', |
| + 'HTMLFieldSetElement': 'fieldset', |
| + 'HTMLFontElement': 'font', |
| + 'HTMLFormElement': 'form', |
| + 'HTMLFrameElement': 'frame', |
| + 'HTMLFrameSetElement': 'frameset', |
| + 'HTMLHRElement': 'hr', |
| + 'HTMLHeadElement': 'head', |
| + 'HTMLHeadingElement': 'h1', |
| + 'HTMLHtmlElement': 'html', |
| + 'HTMLIFrameElement': 'iframe', |
| + 'HTMLImageElement': 'image', |
| + 'HTMLImageElement': 'img', |
| + 'HTMLInputElement': 'input', |
| + 'HTMLKeygenElement': 'keygen', |
| + 'HTMLLIElement': 'li', |
| + 'HTMLLabelElement': 'label', |
| + 'HTMLLegendElement': 'legend', |
| + 'HTMLLinkElement': 'link', |
| + 'HTMLMapElement': 'map', |
| + 'HTMLMarqueeElement': 'marquee', |
| + 'HTMLMenuElement': 'menu', |
| + 'HTMLMetaElement': 'meta', |
| + 'HTMLMeterElement': 'meter', |
| + 'HTMLModElement': 'del', |
|
Jennifer Messerly
2013/08/29 20:57:29
there are a few duplicate entries here. How do we
blois
2013/08/29 21:38:41
It's actually only the polyfill which needs this-
Jennifer Messerly
2013/08/29 22:44:27
okay, that makes sense, but surely we need that pa
|
| + 'HTMLModElement': 'ins', |
| + 'HTMLOListElement': 'ol', |
| + 'HTMLObjectElement': 'object', |
| + 'HTMLOptGroupElement': 'optgroup', |
| + 'HTMLOptionElement': 'option', |
| + 'HTMLOutputElement': 'output', |
| + 'HTMLParagraphElement': 'p', |
| + 'HTMLParamElement': 'param', |
| + 'HTMLPreElement': 'pre', |
| + 'HTMLProgressElement': 'progress', |
| + 'HTMLQuoteElement': 'blockquote', |
| + 'HTMLQuoteElement': 'q', |
| + 'HTMLScriptElement': 'script', |
| + 'HTMLSelectElement': 'select', |
| + 'HTMLShadowElement': 'shadow', |
| + 'HTMLSourceElement': 'source', |
| + 'HTMLSpanElement': 'span', |
| + 'HTMLStyleElement': 'style', |
| + 'HTMLTableCaptionElement': 'caption', |
| + 'HTMLTableCellElement': 'td', |
| + 'HTMLTableColElement': 'col', |
| + 'HTMLTableElement': 'table', |
| + 'HTMLTableRowElement': 'tr', |
| + 'HTMLTableSectionElement': 'tbody', |
| + 'HTMLTableSectionElement': 'tfoot', |
| + 'HTMLTableSectionElement': 'thead', |
| + 'HTMLTextAreaElement': 'textarea', |
| + 'HTMLTitleElement': 'title', |
| + 'HTMLTrackElement': 'track', |
| + 'HTMLUListElement': 'ul', |
| + 'HTMLVideoElement': 'video', |
| +}; |
| + |
| void _registerCustomElement(context, document, String tag, Type type) { |
| // Function follows the same pattern as the following JavaScript code for |
| // registering a custom element. |
| @@ -60,6 +133,13 @@ void _registerCustomElement(context, document, String tag, Type type) { |
| setNativeSubclassDispatchRecord(proto, interceptor); |
| - JS('void', '#.register(#, #)', |
| - document, tag, JS('', '{prototype: #}', proto)); |
| + var options = JS('=Object', '{prototype: #}', proto); |
| + |
| + if (baseClassName != 'HTMLElement') { |
| + if (_typeNameToTag.containsKey(baseClassName)) { |
| + JS('=Object', '#.extends = #', options, _typeNameToTag[baseClassName]); |
| + } |
| + } |
| + |
| + JS('void', '#.register(#, #)', document, tag, options); |
| } |