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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 1401063003: Extension support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged Created 5 years, 2 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:
Download patch
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index a77cddabed6779e9ed70265014261f84e6af0f3c..71db91da247c7dc451784fb2210988405a99c90f 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -1108,13 +1108,30 @@ Function _getSvgFunction(String key) {
******************************************************************************/
// List of known tagName to DartClass for custom elements, used for upgrade.
-var _knownCustomElements = new Map<String, Type>();
+var _knownCustomElements = new Map<String, Map<Type, String>>();
-void _addCustomElementType(String tagName, Type dartClass) {
- _knownCustomElements[tagName] = dartClass;
+void _addCustomElementType(String tagName, Type dartClass, [String extendTag]) {
+ _knownCustomElements[tagName] =
+ {'type': dartClass, 'extends': extendTag != null ? extendTag : "" };
}
-Type _getCustomElementType(object) => _knownCustomElements[_getCustomElementName(object)];
+Type _getCustomElementType(object) {
+ var entry = _knownCustomElements[_getCustomElementName(object)];
+ if (entry != null) {
+ return entry['type'];
+ }
+ return null;
+}
+
+String _getCustomElementExtends(object) {
+ var entry = _knownCustomElements[_getCustomElementName(object)];
+ if (entry != null) {
+ return entry['extends'];
+ }
+ return null;
+}
+
+_getCustomElement(object) => _knownCustomElements[_getCustomElementName(object)];
// Return the tag name or is attribute of the custom element or data binding.
String _getCustomElementName(element) {
@@ -1243,9 +1260,15 @@ wrap_jso(jsObject) {
// make sure it's upgraded.
dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']);
} else {
- var customElementClass = _getCustomElementType(jsObject);
+ var customElementClass = null;
+ var extendsTag = "";
+ var custom = _getCustomElement(jsObject);
+ if (custom != null) {
+ customElementClass = custom['type'];
+ extendsTag = custom['extends'];
+ }
// Custom Element to upgrade.
- if (jsTypeName == 'HTMLElement' && customElementClass != null) {
+ if (jsTypeName == 'HTMLElement' && customElementClass != null && extendsTag == "") {
try {
dartClass_instance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
} finally {
@@ -20424,8 +20447,6 @@ class HtmlDocument extends Document {
*/
void registerElement(String tag, Type customElementClass,
{String extendsTag}) {
- // TODO(terry): Need to handle the extendsTag.
-
// Figure out which DOM class is being extended from the user's Dart class.
var classMirror = reflectClass(customElementClass);
@@ -20459,7 +20480,7 @@ class HtmlDocument extends Document {
var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]);
// Remember for any upgrading done in wrap_jso.
- _addCustomElementType(tag, customElementClass);
+ _addCustomElementType(tag, customElementClass, extendsTag);
// TODO(terry): Hack to stop recursion re-creating custom element when the
// created() constructor of the custom element does e.g.,
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698