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

Unified Diff: pkg/web_components/lib/dart_support.js

Issue 335463003: Report error only for elements we intend to upgrade. (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/dart_support.js
diff --git a/pkg/web_components/lib/dart_support.js b/pkg/web_components/lib/dart_support.js
index 77948eb29438f24008c56db0078bc50a54249610..895adcc92803b21b3e9bdd69df710d0ee8c1ed98 100644
--- a/pkg/web_components/lib/dart_support.js
+++ b/pkg/web_components/lib/dart_support.js
@@ -68,12 +68,19 @@
// Updates document.registerElement so Dart can see when Javascript custom
// elements are created, and wrap them to provide a Dart friendly API.
(function (doc) {
- var upgraders = {};
+ var upgraders = {}; // upgrader associated with a custom-tag.
+ var unpatchableTags = {}; // set of custom-tags that can't be patched.
var originalRegisterElement = doc.registerElement;
if (!originalRegisterElement) {
throw new Error('document.registerElement is not present.');
}
+ function reportError(name) {
+ console.error("Couldn't patch prototype to notify Dart when " + name +
+ " elements are created. This can be fixed by making the " +
+ "createdCallback in " + name + " a configurable property.");
+ }
+
function registerElement(name, options) {
var proto, extendsOption;
if (options !== undefined) {
@@ -98,9 +105,8 @@
descriptor['value'] = newCallback;
Object.defineProperty(proto, 'createdCallback', descriptor);
} else {
- console.error("Couldn't patch prototype to notify Dart when " + name +
- " elements are created. This can be fixed by making the " +
- "createdCallback in " + name + " a configurable property.");
+ unpatchableTags[name] = true;
+ if (!!upgraders[name]) reportError(name);
Jennifer Messerly 2014/06/12 00:51:05 I don't think !! is needed here.
Siggi Cherem (dart-lang) 2014/06/12 01:03:23 Done.
}
return originalRegisterElement.call(this, name, options);
}
@@ -114,6 +120,7 @@
return;
}
upgraders[name] = upgrader;
+ if (unpatchableTags[name]) reportError(name);
}
« 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