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

Unified Diff: pkg/web_components/lib/interop.dart

Issue 341003002: web_components: fix extending another custom element (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | pkg/web_components/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/web_components/lib/interop.dart
diff --git a/pkg/web_components/lib/interop.dart b/pkg/web_components/lib/interop.dart
index 415c7feae439fbe9864c8baf8414deb75ac4bf46..de1ef2fb8885d0b970f4cba783f96b539ae74e07 100644
--- a/pkg/web_components/lib/interop.dart
+++ b/pkg/web_components/lib/interop.dart
@@ -29,7 +29,17 @@ void registerDartType(String tagName, Type dartType, {String extendsTag}) {
var upgrader = document.createElementUpgrader(
dartType, extendsTag: extendsTag);
- _doc.callMethod('_registerDartTypeUpgrader', [tagName, upgrader.upgrade]);
+
+ // Unfortunately the dart:html upgrader will throw on an already-upgraded
+ // element, so we need to duplicate the type check to prevent that.
+ // An element can be upgraded twice if it extends another element and calls
+ // createdCallback on the superclass. Since that's a valid use case we must
+ // wrap at both levels, and guard against it here.
+ upgradeElement(e) {
+ if (e.runtimeType != dartType) upgrader.upgrade(e);
+ }
+
+ _doc.callMethod('_registerDartTypeUpgrader', [tagName, upgradeElement]);
}
/// This function is mainly used to save resources. By default, we save a log of
« no previous file with comments | « no previous file | pkg/web_components/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698