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

Unified Diff: pkg/polymer/lib/src/instance.dart

Issue 290113002: [polymer] add a new API to create an element without polymer-element in HTML (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/polymer/test/register_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/instance.dart
diff --git a/pkg/polymer/lib/src/instance.dart b/pkg/polymer/lib/src/instance.dart
index 96c8698d2395b19f69a626cf01071d8172a0c8b1..4dcca03e6fc4c60c0160607b0dd1cf6fa6bfa05e 100644
--- a/pkg/polymer/lib/src/instance.dart
+++ b/pkg/polymer/lib/src/instance.dart
@@ -79,6 +79,26 @@ abstract class Polymer implements Element, Observable, NodeBindExtension {
(js.context['Polymer'] as JsFunction).apply([name]);
}
+ /// Register a custom element that has no associated `<polymer-element>`.
+ /// Unlike [register] this will always perform synchronous registration and
+ /// by the time this method returns the element will be available using
+ /// [document.createElement] or by modifying the HTML to include the element.
+ static void registerSync(String name, Type type,
+ {String extendsTag, Document doc, Node template}) {
+
+ // Our normal registration, this will queue up the name->type association.
+ register(name, type);
+
+ // Build a polymer-element and initialize it to register
+ if (doc == null) doc = document;
+ var poly = doc.createElement('polymer-element');
+ poly.attributes['name'] = name;
+ if (extendsTag != null) poly.attributes['extends'] = extendsTag;
+ if (template != null) poly.append(template);
+
+ new JsObject.fromBrowserObject(poly).callMethod('init');
+ }
+
/// The one syntax to rule them all.
static final BindingDelegate _polymerSyntax =
new PolymerExpressionsWithEvents();
« no previous file with comments | « no previous file | pkg/polymer/test/register_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698