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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/polymer/test/register_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of polymer; 5 part of polymer;
6 6
7 /// Use this annotation to publish a field as an attribute. For example: 7 /// Use this annotation to publish a field as an attribute. For example:
8 /// 8 ///
9 /// class MyPlaybackElement extends PolymerElement { 9 /// class MyPlaybackElement extends PolymerElement {
10 /// // This will be available as an HTML attribute, for example: 10 /// // This will be available as an HTML attribute, for example:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (type == null) type = PolymerElement; 72 if (type == null) type = PolymerElement;
73 73
74 _typesByName[name] = type; 74 _typesByName[name] = type;
75 75
76 // Dart note: here we notify JS of the element registration. We don't pass 76 // Dart note: here we notify JS of the element registration. We don't pass
77 // the Dart type because we will handle that in PolymerDeclaration. 77 // the Dart type because we will handle that in PolymerDeclaration.
78 // See _hookJsPolymerDeclaration for how this is done. 78 // See _hookJsPolymerDeclaration for how this is done.
79 (js.context['Polymer'] as JsFunction).apply([name]); 79 (js.context['Polymer'] as JsFunction).apply([name]);
80 } 80 }
81 81
82 /// Register a custom element that has no associated `<polymer-element>`.
83 /// Unlike [register] this will always perform synchronous registration and
84 /// by the time this method returns the element will be available using
85 /// [document.createElement] or by modifying the HTML to include the element.
86 static void registerSync(String name, Type type,
87 {String extendsTag, Document doc, Node template}) {
88
89 // Our normal registration, this will queue up the name->type association.
90 register(name, type);
91
92 // Build a polymer-element and initialize it to register
93 if (doc == null) doc = document;
94 var poly = doc.createElement('polymer-element');
95 poly.attributes['name'] = name;
96 if (extendsTag != null) poly.attributes['extends'] = extendsTag;
97 if (template != null) poly.append(template);
98
99 new JsObject.fromBrowserObject(poly).callMethod('init');
100 }
101
82 /// The one syntax to rule them all. 102 /// The one syntax to rule them all.
83 static final BindingDelegate _polymerSyntax = 103 static final BindingDelegate _polymerSyntax =
84 new PolymerExpressionsWithEvents(); 104 new PolymerExpressionsWithEvents();
85 105
86 static int _preparingElements = 0; 106 static int _preparingElements = 0;
87 107
88 static final Completer _ready = new Completer(); 108 static final Completer _ready = new Completer();
89 109
90 /// Future indicating that the Polymer library has been loaded and is ready 110 /// Future indicating that the Polymer library has been loaded and is ready
91 /// for use. 111 /// for use.
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 if (_sub != null) { 1041 if (_sub != null) {
1022 if (_eventsLog.isLoggable(Level.FINE)) { 1042 if (_eventsLog.isLoggable(Level.FINE)) {
1023 _eventsLog.fine( 1043 _eventsLog.fine(
1024 'event.remove: [$_node].$_eventName => [$_model].$_path())'); 1044 'event.remove: [$_node].$_eventName => [$_model].$_path())');
1025 } 1045 }
1026 _sub.cancel(); 1046 _sub.cancel();
1027 _sub = null; 1047 _sub = null;
1028 } 1048 }
1029 } 1049 }
1030 } 1050 }
OLDNEW
« 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