OLD | NEW |
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. | 7 /// Use this annotation to publish a field as an attribute. |
8 /// | 8 /// |
9 /// You can also use [PublishedProperty] to provide additional information, | 9 /// You can also use [PublishedProperty] to provide additional information, |
10 /// such as automatically syncing the property back to the attribute. | 10 /// such as automatically syncing the property back to the attribute. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Our normal registration, this will queue up the name->type association. | 125 // Our normal registration, this will queue up the name->type association. |
126 register(name, type); | 126 register(name, type); |
127 | 127 |
128 // Build a polymer-element and initialize it to register | 128 // Build a polymer-element and initialize it to register |
129 if (doc == null) doc = document; | 129 if (doc == null) doc = document; |
130 var poly = doc.createElement('polymer-element'); | 130 var poly = doc.createElement('polymer-element'); |
131 poly.attributes['name'] = name; | 131 poly.attributes['name'] = name; |
132 if (extendsTag != null) poly.attributes['extends'] = extendsTag; | 132 if (extendsTag != null) poly.attributes['extends'] = extendsTag; |
133 if (template != null) poly.append(template); | 133 if (template != null) poly.append(template); |
134 | 134 |
135 new JsObject.fromBrowserObject(poly).callMethod('init'); | 135 // TODO(jmesserly): conceptually this is just: |
| 136 // new JsObject.fromBrowserObject(poly).callMethod('init') |
| 137 // |
| 138 // However doing it that way hits an issue with JS-interop in IE10: we get a |
| 139 // JsObject that wraps something other than `poly`, due to improper caching. |
| 140 // By reusing _polymerElementProto that we used for 'register', we can |
| 141 // then call apply on it to invoke init() with the correct `this` pointer. |
| 142 JsFunction init = _polymerElementProto['init']; |
| 143 init.apply([], thisArg: poly); |
136 } | 144 } |
137 | 145 |
138 // Note: these are from src/declaration/import.js | 146 // Note: these are from src/declaration/import.js |
139 // For now proxy to the JS methods, because we want to share the loader with | 147 // For now proxy to the JS methods, because we want to share the loader with |
140 // polymer.js for interop purposes. | 148 // polymer.js for interop purposes. |
141 static Future importElements(Node elementOrFragment) { | 149 static Future importElements(Node elementOrFragment) { |
142 var completer = new Completer(); | 150 var completer = new Completer(); |
143 js.context['Polymer'].callMethod('importElements', | 151 js.context['Polymer'].callMethod('importElements', |
144 [elementOrFragment, () => completer.complete()]); | 152 [elementOrFragment, () => completer.complete()]); |
145 return completer.future; | 153 return completer.future; |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1118 |
1111 final Logger _observeLog = new Logger('polymer.observe'); | 1119 final Logger _observeLog = new Logger('polymer.observe'); |
1112 final Logger _eventsLog = new Logger('polymer.events'); | 1120 final Logger _eventsLog = new Logger('polymer.events'); |
1113 final Logger _unbindLog = new Logger('polymer.unbind'); | 1121 final Logger _unbindLog = new Logger('polymer.unbind'); |
1114 final Logger _bindLog = new Logger('polymer.bind'); | 1122 final Logger _bindLog = new Logger('polymer.bind'); |
1115 | 1123 |
1116 final Expando _eventHandledTable = new Expando<Set<Node>>(); | 1124 final Expando _eventHandledTable = new Expando<Set<Node>>(); |
1117 | 1125 |
1118 final JsObject _PolymerGestures = js.context['PolymerGestures']; | 1126 final JsObject _PolymerGestures = js.context['PolymerGestures']; |
1119 | 1127 |
OLD | NEW |