Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: tools/dom/src/dart2js_CustomElementSupport.dart

Issue 23190026: Type extension support in polyfill. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698