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

Side by Side Diff: pkg/polymer/lib/src/declaration.dart

Issue 182193002: [polymer] interop with polymer-element and polymer.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « pkg/polymer/lib/src/boot.dart ('k') | pkg/polymer/lib/src/instance.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 /// **Warning**: this class is experiental and subject to change. 7 /// *Warning* this class is experimental and subject to change.
8 /// 8 ///
9 /// The implementation for the `polymer-element` element. 9 /// The data associated with a polymer-element declaration, if it is backed
10 /// 10 /// by a Dart class instead of a JavaScript prototype.
11 /// Normally you do not need to use this class directly, see [PolymerElement]. 11 class PolymerDeclaration {
12 class PolymerDeclaration extends HtmlElement { 12 /// The polymer-element for this declaration.
13 static const _TAG = 'polymer-element'; 13 final HtmlElement element;
14 14
15 factory PolymerDeclaration() => new Element.tag(_TAG); 15 /// The Dart type corresponding to this custom element declaration.
16 // Fully ported from revision: 16 final Type type;
17 // https://github.com/Polymer/polymer/blob/b7200854b2441a22ce89f6563963f36c50f 5150d
18 //
19 // src/declaration/attributes.js
20 // src/declaration/events.js
21 // src/declaration/polymer-element.js
22 // src/declaration/properties.js
23 // src/declaration/prototype.js (note: most code not needed in Dart)
24 // src/declaration/styles.js
25 //
26 // Not yet ported:
27 // src/declaration/path.js - blocked on HTMLImports.getDocumentUrl
28 17
29 Type _type; 18 /// If we extend another custom element, this points to the super declaration.
30 Type get type => _type; 19 final PolymerDeclaration superDeclaration;
31 20
32 // TODO(jmesserly): this is a cache, because it's tricky in Dart to get from 21 /// The name of the custom element.
33 // Type -> Supertype. 22 final String name;
34 Type _supertype;
35 Type get supertype => _supertype;
36
37 // TODO(jmesserly): this is also a cache, since we can't store .element on
38 // each level of the __proto__ like JS does.
39 PolymerDeclaration _super;
40 PolymerDeclaration get superDeclaration => _super;
41
42 String _extendsName;
43
44 String _name;
45 String get name => _name;
46 23
47 /// Map of publish properties. Can be a field or a property getter, but if 24 /// Map of publish properties. Can be a field or a property getter, but if
48 /// this map contains a getter, is because it also has a corresponding setter. 25 /// this map contains a getter, is because it also has a corresponding setter.
49 /// 26 ///
50 /// Note: technically these are always single properties, so we could use a 27 /// Note: technically these are always single properties, so we could use a
51 /// Symbol instead of a PropertyPath. However there are lookups between this 28 /// Symbol instead of a PropertyPath. However there are lookups between this
52 /// map and [_observe] so it is easier to just track paths. 29 /// map and [_observe] so it is easier to just track paths.
53 Map<PropertyPath, smoke.Declaration> _publish; 30 Map<PropertyPath, smoke.Declaration> _publish;
54 31
55 /// The names of published properties for this polymer-element. 32 /// The names of published properties for this polymer-element.
56 Iterable<String> get publishedProperties => 33 Iterable<String> get publishedProperties =>
57 _publish != null ? _publish.keys.map((p) => '$p') : const []; 34 _publish != null ? _publish.keys.map((p) => '$p') : const [];
58 35
59 /// Same as [_publish] but with lower case names. 36 /// Same as [_publish] but with lower case names.
60 Map<String, smoke.Declaration> _publishLC; 37 Map<String, smoke.Declaration> _publishLC;
61 38
62 Map<PropertyPath, List<Symbol>> _observe; 39 Map<PropertyPath, List<Symbol>> _observe;
63 40
64 Map<String, Object> _instanceAttributes; 41 Map<String, Object> _instanceAttributes;
65 42
66 List<Element> _sheets; 43 List<Element> _sheets;
67 List<Element> get sheets => _sheets; 44 List<Element> get sheets => _sheets;
68 45
69 List<Element> _styles; 46 List<Element> _styles;
70 List<Element> get styles => _styles; 47 List<Element> get styles => _styles;
71 48
72 DocumentFragment get templateContent { 49 DocumentFragment get templateContent {
73 final template = this.querySelector('template'); 50 final template = element.querySelector('template');
74 return template != null ? templateBind(template).content : null; 51 return template != null ? templateBind(template).content : null;
75 } 52 }
76 53
77 /// Maps event names and their associated method in the element class. 54 /// Maps event names and their associated method in the element class.
78 final Map<String, String> _eventDelegates = {}; 55 final Map<String, String> _eventDelegates = {};
79 56
80 /// Expected events per element node. 57 /// Expected events per element node.
81 // TODO(sigmund): investigate whether we need more than 1 set of local events 58 // TODO(sigmund): investigate whether we need more than 1 set of local events
82 // per element (why does the js implementation stores 1 per template node?) 59 // per element (why does the js implementation stores 1 per template node?)
83 Expando<Set<String>> _templateDelegates; 60 Expando<Set<String>> _templateDelegates;
84 61
85 PolymerDeclaration.created() : super.created() { 62 String get extendee => superDeclaration != null ?
86 // fetch the element name 63 superDeclaration.name : null;
87 _name = attributes['name'];
88 // fetch our extendee name
89 _extendsName = attributes['extends'];
90 // install element definition, if ready
91 registerWhenReady();
92 }
93 64
94 void registerWhenReady() { 65 // Dart note: since polymer-element is handled in JS now, we have a simplified
95 // if we have no prototype, wait 66 // flow for registering. We don't need to wait for the supertype or the code
96 if (waitingForType(name)) { 67 // to be noticed.
97 return; 68 PolymerDeclaration(this.element, this.name, this.type, this.superDeclaration);
98 }
99 if (waitingForExtendee(_extendsName)) {
100 //console.warn(name + ': waitingForExtendee:' + extendee);
101 return;
102 }
103 // TODO(sjmiles): HTMLImports polyfill awareness:
104 // elements in the main document are likely to parse
105 // in advance of elements in imports because the
106 // polyfill parser is simulated
107 // therefore, wait for imports loaded before
108 // finalizing elements in the main document
109 // TODO(jmesserly): Polymer.dart waits for HTMLImportsLoaded, so I've
110 // removed "whenImportsLoaded" for now. Restore the workaround if needed.
111 _register(_extendsName);
112 }
113 69
114 void _register(extendee) { 70 void register() {
115 //console.group('registering', name);
116 register(name, extendee);
117 //console.groupEnd();
118 // subclasses may now register themselves
119 _notifySuper(name);
120 }
121
122 bool waitingForType(String name) {
123 if (_getRegisteredType(name) != null) return false;
124
125 // then wait for a prototype
126 _waitType[name] = this;
127 // if explicitly marked as 'noscript'
128 if (attributes.containsKey('noscript')) {
129 // TODO(sorvell): CustomElements polyfill awareness:
130 // noscript elements should upgrade in logical order
131 // script injection ensures this under native custom elements;
132 // under imports + ce polyfills, scripts run before upgrades.
133 // dependencies should be ready at upgrade time so register
134 // prototype at this time.
135 // TODO(jmesserly): I'm not sure how to port this; since script
136 // injection doesn't work for Dart, we'll just call Polymer.register
137 // here and hope for the best.
138 Polymer.register(name);
139 }
140 return true;
141 }
142
143 bool waitingForExtendee(String extendee) {
144 // if extending a custom element...
145 if (extendee != null && extendee.indexOf('-') >= 0) {
146 // wait for the extendee to be _registered first
147 if (!_isRegistered(extendee)) {
148 _waitSuper.putIfAbsent(extendee, () => []).add(this);
149 return true;
150 }
151 }
152 return false;
153 }
154
155 void register(String name, String extendee) {
156 // build prototype combining extendee, Polymer base, and named api 71 // build prototype combining extendee, Polymer base, and named api
157 buildType(name, extendee); 72 buildType();
158 73
159 // back reference declaration element 74 // back reference declaration element
160 // TODO(sjmiles): replace `element` with `elementElement` or `declaration` 75 // TODO(sjmiles): replace `element` with `elementElement` or `declaration`
161 _declarations[name] = this; 76 _declarations[name] = this;
162 77
163 // more declarative features 78 // more declarative features
164 desugar(name, extendee); 79 desugar();
165 // register our custom element 80 // register our custom element
166 registerType(name); 81 registerType(name);
167 82
168 // NOTE: skip in Dart because we don't have mutable global scope. 83 // NOTE: skip in Dart because we don't have mutable global scope.
169 // reference constructor in a global named by 'constructor' attribute 84 // reference constructor in a global named by 'constructor' attribute
170 // publishConstructor(); 85 // publishConstructor();
171 } 86 }
172 87
173 /// Gets the Dart type registered for this name, and sets up declarative 88 /// Gets the Dart type registered for this name, and sets up declarative
174 /// features. Fills in the [type] and [supertype] fields. 89 /// features. Fills in the [type] and [supertype] fields.
175 /// 90 ///
176 /// *Note*: unlike the JavaScript version, we do not have to metaprogram the 91 /// *Note*: unlike the JavaScript version, we do not have to metaprogram the
177 /// prototype, which simplifies this method. 92 /// prototype, which simplifies this method.
178 void buildType(String name, String extendee) { 93 void buildType() {
179 // get our custom type
180 _type = _getRegisteredType(name);
181
182 // get basal prototype
183 _supertype = _getRegisteredType(extendee);
184 if (_supertype != null) _super = _getDeclaration(extendee);
185
186 // transcribe `attributes` declarations onto own prototype's `publish` 94 // transcribe `attributes` declarations onto own prototype's `publish`
187 publishAttributes(_super); 95 publishAttributes(superDeclaration);
188 96
189 publishProperties(); 97 publishProperties();
190 98
191 inferObservers(); 99 inferObservers();
192 100
193 // desugar compound observer syntax, e.g. @ObserveProperty('a b c') 101 // desugar compound observer syntax, e.g. @ObserveProperty('a b c')
194 explodeObservers(); 102 explodeObservers();
195 103
196 // Skip the rest in Dart: 104 // Skip the rest in Dart:
197 // chain various meta-data objects to inherited versions 105 // chain various meta-data objects to inherited versions
198 // chain custom api to inherited 106 // chain custom api to inherited
199 // build side-chained lists to optimize iterations 107 // build side-chained lists to optimize iterations
200 // inherit publishing meta-data 108 // inherit publishing meta-data
201 // x-platform fixup 109 // x-platform fixup
202 } 110 }
203 111
204 /// Implement various declarative features. 112 /// Implement various declarative features.
205 void desugar(name, extendee) { 113 void desugar() {
206 // compile list of attributes to copy to instances 114 // compile list of attributes to copy to instances
207 accumulateInstanceAttributes(); 115 accumulateInstanceAttributes();
208 // parse on-* delegates declared on `this` element 116 // parse on-* delegates declared on `this` element
209 parseHostEvents(); 117 parseHostEvents();
210 // install external stylesheets as if they are inline 118 // install external stylesheets as if they are inline
211 installSheets(); 119 installSheets();
212 120
213 adjustShadowElement(); 121 adjustShadowElement();
214 122
215 // TODO(sorvell): install a helper method this.resolvePath to aid in 123 // TODO(sorvell): install a helper method this.resolvePath to aid in
(...skipping 26 matching lines...) Expand all
242 for (var s in content.querySelectorAll('shadow')) { 150 for (var s in content.querySelectorAll('shadow')) {
243 if (s.nodes.isEmpty) s.append(new ContentElement()); 151 if (s.nodes.isEmpty) s.append(new ContentElement());
244 } 152 }
245 } 153 }
246 } 154 }
247 155
248 void registerType(String name) { 156 void registerType(String name) {
249 var baseTag; 157 var baseTag;
250 var decl = this; 158 var decl = this;
251 while (decl != null) { 159 while (decl != null) {
252 baseTag = decl.attributes['extends']; 160 baseTag = decl.element.attributes['extends'];
253 decl = decl.superDeclaration; 161 decl = decl.superDeclaration;
254 } 162 }
255 document.register(name, type, extendsTag: baseTag); 163 document.register(name, type, extendsTag: baseTag);
256 } 164 }
257 165
258 void publishAttributes(PolymerDeclaration superDecl) { 166 void publishAttributes(PolymerDeclaration superDecl) {
259 // get properties to publish 167 // get properties to publish
260 if (superDecl != null && superDecl._publish != null) { 168 if (superDecl != null && superDecl._publish != null) {
261 // Dart note: even though we walk the type hierarchy in 169 // Dart note: even though we walk the type hierarchy in
262 // _getPublishedProperties, this will additionally include any names 170 // _getPublishedProperties, this will additionally include any names
263 // published via the `attributes` attribute. 171 // published via the `attributes` attribute.
264 _publish = new Map.from(superDecl._publish); 172 _publish = new Map.from(superDecl._publish);
265 } 173 }
266 174
267 _publish = _getPublishedProperties(_type, _publish); 175 _publish = _getPublishedProperties(type, _publish);
268 176
269 // merge names from 'attributes' attribute 177 // merge names from 'attributes' attribute
270 var attrs = attributes['attributes']; 178 var attrs = element.attributes['attributes'];
271 if (attrs != null) { 179 if (attrs != null) {
272 // names='a b c' or names='a,b,c' 180 // names='a b c' or names='a,b,c'
273 // record each name for publishing 181 // record each name for publishing
274 for (var attr in attrs.split(_ATTRIBUTES_REGEX)) { 182 for (var attr in attrs.split(_ATTRIBUTES_REGEX)) {
275 // remove excess ws 183 // remove excess ws
276 attr = attr.trim(); 184 attr = attr.trim();
277 185
278 // do not override explicit entries 186 // do not override explicit entries
279 if (attr == '') continue; 187 if (attr == '') continue;
280 188
281 var property = new Symbol(attr); 189 var property = new Symbol(attr);
282 var path = new PropertyPath([property]); 190 var path = new PropertyPath([property]);
283 if (_publish != null && _publish.containsKey(path)) { 191 if (_publish != null && _publish.containsKey(path)) {
284 continue; 192 continue;
285 } 193 }
286 194
287 var decl = smoke.getDeclaration(_type, property); 195 var decl = smoke.getDeclaration(type, property);
288 if (decl == null || decl.isMethod || decl.isFinal) { 196 if (decl == null || decl.isMethod || decl.isFinal) {
289 window.console.warn('property for attribute $attr of polymer-element ' 197 window.console.warn('property for attribute $attr of polymer-element '
290 'name=$name not found.'); 198 'name=$name not found.');
291 continue; 199 continue;
292 } 200 }
293 if (_publish == null) _publish = {}; 201 if (_publish == null) _publish = {};
294 _publish[path] = decl; 202 _publish[path] = decl;
295 } 203 }
296 } 204 }
297 205
298 // NOTE: the following is not possible in Dart; fields must be declared. 206 // NOTE: the following is not possible in Dart; fields must be declared.
299 // install 'attributes' as properties on the prototype, 207 // install 'attributes' as properties on the prototype,
300 // but don't override 208 // but don't override
301 } 209 }
302 210
303 void accumulateInstanceAttributes() { 211 void accumulateInstanceAttributes() {
304 // inherit instance attributes 212 // inherit instance attributes
305 _instanceAttributes = new Map<String, Object>(); 213 _instanceAttributes = new Map<String, Object>();
306 if (_super != null) _instanceAttributes.addAll(_super._instanceAttributes); 214 if (superDeclaration != null) {
215 _instanceAttributes.addAll(superDeclaration._instanceAttributes);
216 }
307 217
308 // merge attributes from element 218 // merge attributes from element
309 attributes.forEach((name, value) { 219 element.attributes.forEach((name, value) {
310 if (isInstanceAttribute(name)) { 220 if (isInstanceAttribute(name)) {
311 _instanceAttributes[name] = value; 221 _instanceAttributes[name] = value;
312 } 222 }
313 }); 223 });
314 } 224 }
315 225
316 static bool isInstanceAttribute(name) { 226 static bool isInstanceAttribute(name) {
317 // do not clone these attributes onto instances 227 // do not clone these attributes onto instances
318 final blackList = const { 228 final blackList = const {
319 'name': 1, 'extends': 1, 'constructor': 1, 'noscript': 1, 229 'name': 1, 'extends': 1, 'constructor': 1, 'noscript': 1,
320 'attributes': 1}; 230 'attributes': 1};
321 231
322 return !blackList.containsKey(name) && !name.startsWith('on-'); 232 return !blackList.containsKey(name) && !name.startsWith('on-');
323 } 233 }
324 234
325 /// Extracts events from the element tag attributes. 235 /// Extracts events from the element tag attributes.
326 void parseHostEvents() { 236 void parseHostEvents() {
327 addAttributeDelegates(_eventDelegates); 237 addAttributeDelegates(_eventDelegates);
328 } 238 }
329 239
330 void addAttributeDelegates(Map<String, String> delegates) { 240 void addAttributeDelegates(Map<String, String> delegates) {
331 attributes.forEach((name, value) { 241 element.attributes.forEach((name, value) {
332 if (_hasEventPrefix(name)) { 242 if (_hasEventPrefix(name)) {
333 var start = value.indexOf('{{'); 243 var start = value.indexOf('{{');
334 var end = value.lastIndexOf('}}'); 244 var end = value.lastIndexOf('}}');
335 if (start >= 0 && end >= 0) { 245 if (start >= 0 && end >= 0) {
336 delegates[_removeEventPrefix(name)] = 246 delegates[_removeEventPrefix(name)] =
337 value.substring(start + 2, end).trim(); 247 value.substring(start + 2, end).trim();
338 } 248 }
339 } 249 }
340 }); 250 });
341 } 251 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 291 }
382 if (cssText.length > 0) { 292 if (cssText.length > 0) {
383 content.insertBefore( 293 content.insertBefore(
384 new StyleElement()..text = '$cssText', 294 new StyleElement()..text = '$cssText',
385 content.firstChild); 295 content.firstChild);
386 } 296 }
387 } 297 }
388 } 298 }
389 299
390 List<Element> findNodes(String selector, [bool matcher(Element e)]) { 300 List<Element> findNodes(String selector, [bool matcher(Element e)]) {
391 var nodes = this.querySelectorAll(selector).toList(); 301 var nodes = element.querySelectorAll(selector).toList();
392 var content = templateContent; 302 var content = templateContent;
393 if (content != null) { 303 if (content != null) {
394 nodes = nodes..addAll(content.querySelectorAll(selector)); 304 nodes = nodes..addAll(content.querySelectorAll(selector));
395 } 305 }
396 if (matcher != null) return nodes.where(matcher).toList(); 306 if (matcher != null) return nodes.where(matcher).toList();
397 return nodes; 307 return nodes;
398 } 308 }
399 309
400 /// Promotes external stylesheets and style elements with the attribute 310 /// Promotes external stylesheets and style elements with the attribute
401 /// polymer-scope='global' into global scope. 311 /// polymer-scope='global' into global scope.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 ..text = cssText 346 ..text = cssText
437 ..attributes[_STYLE_SCOPE_ATTRIBUTE] = '$name-$scopeDescriptor'; 347 ..attributes[_STYLE_SCOPE_ATTRIBUTE] = '$name-$scopeDescriptor';
438 } 348 }
439 349
440 /// Fetch a list of all *Changed methods so we can observe the associated 350 /// Fetch a list of all *Changed methods so we can observe the associated
441 /// properties. 351 /// properties.
442 void inferObservers() { 352 void inferObservers() {
443 var options = const smoke.QueryOptions(includeFields: false, 353 var options = const smoke.QueryOptions(includeFields: false,
444 includeProperties: false, includeMethods: true, includeInherited: true, 354 includeProperties: false, includeMethods: true, includeInherited: true,
445 includeUpTo: HtmlElement); 355 includeUpTo: HtmlElement);
446 for (var decl in smoke.query(_type, options)) { 356 for (var decl in smoke.query(type, options)) {
447 String name = smoke.symbolToName(decl.name); 357 String name = smoke.symbolToName(decl.name);
448 if (name.endsWith(_OBSERVE_SUFFIX) && name != 'attributeChanged') { 358 if (name.endsWith(_OBSERVE_SUFFIX) && name != 'attributeChanged') {
449 // TODO(jmesserly): now that we have a better system, should we 359 // TODO(jmesserly): now that we have a better system, should we
450 // deprecate *Changed methods? 360 // deprecate *Changed methods?
451 if (_observe == null) _observe = new HashMap(); 361 if (_observe == null) _observe = new HashMap();
452 name = name.substring(0, name.length - 7); 362 name = name.substring(0, name.length - 7);
453 _observe[new PropertyPath(name)] = [decl.name]; 363 _observe[new PropertyPath(name)] = [decl.name];
454 } 364 }
455 } 365 }
456 } 366 }
457 367
458 /// Fetch a list of all methods annotated with [ObserveProperty] so we can 368 /// Fetch a list of all methods annotated with [ObserveProperty] so we can
459 /// observe the associated properties. 369 /// observe the associated properties.
460 void explodeObservers() { 370 void explodeObservers() {
461 var options = const smoke.QueryOptions(includeFields: false, 371 var options = const smoke.QueryOptions(includeFields: false,
462 includeProperties: false, includeMethods: true, includeInherited: true, 372 includeProperties: false, includeMethods: true, includeInherited: true,
463 includeUpTo: HtmlElement, withAnnotations: const [ObserveProperty]); 373 includeUpTo: HtmlElement, withAnnotations: const [ObserveProperty]);
464 for (var decl in smoke.query(_type, options)) { 374 for (var decl in smoke.query(type, options)) {
465 for (var meta in decl.annotations) { 375 for (var meta in decl.annotations) {
466 if (meta is! ObserveProperty) continue; 376 if (meta is! ObserveProperty) continue;
467 if (_observe == null) _observe = new HashMap(); 377 if (_observe == null) _observe = new HashMap();
468 for (String name in meta.names) { 378 for (String name in meta.names) {
469 _observe.putIfAbsent(new PropertyPath(name), () => []).add(decl.name); 379 _observe.putIfAbsent(new PropertyPath(name), () => []).add(decl.name);
470 } 380 }
471 } 381 }
472 } 382 }
473 } 383 }
474 384
475 void publishProperties() { 385 void publishProperties() {
476 // Dart note: _publish was already populated by publishAttributes 386 // Dart note: _publish was already populated by publishAttributes
477 if (_publish != null) _publishLC = _lowerCaseMap(_publish); 387 if (_publish != null) _publishLC = _lowerCaseMap(_publish);
478 } 388 }
479 389
480 Map<String, dynamic> _lowerCaseMap(Map<PropertyPath, dynamic> properties) { 390 Map<String, dynamic> _lowerCaseMap(Map<PropertyPath, dynamic> properties) {
481 final map = new Map<String, dynamic>(); 391 final map = new Map<String, dynamic>();
482 properties.forEach((PropertyPath path, value) { 392 properties.forEach((PropertyPath path, value) {
483 map['$path'.toLowerCase()] = value; 393 map['$path'.toLowerCase()] = value;
484 }); 394 });
485 return map; 395 return map;
486 } 396 }
487 } 397 }
488 398
489 /// maps tag names to prototypes 399 /// maps tag names to prototypes
490 final Map _typesByName = new Map<String, Type>(); 400 final Map _typesByName = new Map<String, Type>();
491 401
492 Type _getRegisteredType(String name) => _typesByName[name]; 402 Type _getRegisteredType(String name) => _typesByName[name];
493 403
494 /// elements waiting for prototype, by name
495 final Map _waitType = new Map<String, PolymerDeclaration>();
496
497 void _notifyType(String name) {
498 var waiting = _waitType.remove(name);
499 if (waiting != null) waiting.registerWhenReady();
500 }
501
502 /// elements waiting for super, by name
503 final Map _waitSuper = new Map<String, List<PolymerDeclaration>>();
504
505 void _notifySuper(String name) {
506 var waiting = _waitSuper.remove(name);
507 if (waiting != null) {
508 for (var w in waiting) {
509 w.registerWhenReady();
510 }
511 }
512 }
513
514 /// track document.register'ed tag names and their declarations 404 /// track document.register'ed tag names and their declarations
515 final Map _declarations = new Map<String, PolymerDeclaration>(); 405 final Map _declarations = new Map<String, PolymerDeclaration>();
516 406
517 bool _isRegistered(String name) => _declarations.containsKey(name); 407 bool _isRegistered(String name) => _declarations.containsKey(name);
518 PolymerDeclaration _getDeclaration(String name) => _declarations[name]; 408 PolymerDeclaration _getDeclaration(String name) => _declarations[name];
519 409
520 Map<PropertyPath, smoke.Declaration> _getPublishedProperties( 410 Map<PropertyPath, smoke.Declaration> _getPublishedProperties(
521 Type type, Map<PropertyPath, smoke.Declaration> props) { 411 Type type, Map<PropertyPath, smoke.Declaration> props) {
522 var options = const smoke.QueryOptions(includeInherited: true, 412 var options = const smoke.QueryOptions(includeInherited: true,
523 includeUpTo: HtmlElement, withAnnotations: const [PublishedProperty]); 413 includeUpTo: HtmlElement, withAnnotations: const [PublishedProperty]);
(...skipping 18 matching lines...) Expand all
542 String extendee) { 432 String extendee) {
543 if (template == null || !_hasShadowDomPolyfill) return; 433 if (template == null || !_hasShadowDomPolyfill) return;
544 434
545 var platform = js.context['Platform']; 435 var platform = js.context['Platform'];
546 if (platform == null) return; 436 if (platform == null) return;
547 var shadowCss = platform['ShadowCSS']; 437 var shadowCss = platform['ShadowCSS'];
548 if (shadowCss == null) return; 438 if (shadowCss == null) return;
549 shadowCss.callMethod('shimStyling', [template, name, extendee]); 439 shadowCss.callMethod('shimStyling', [template, name, extendee]);
550 } 440 }
551 441
552 final bool _hasShadowDomPolyfill = js.context != null && 442 final bool _hasShadowDomPolyfill = js.context.hasProperty('ShadowDOMPolyfill');
553 js.context.hasProperty('ShadowDOMPolyfill');
554 443
555 const _STYLE_SELECTOR = 'style'; 444 const _STYLE_SELECTOR = 'style';
556 const _SHEET_SELECTOR = '[rel=stylesheet]'; 445 const _SHEET_SELECTOR = '[rel=stylesheet]';
557 const _STYLE_GLOBAL_SCOPE = 'global'; 446 const _STYLE_GLOBAL_SCOPE = 'global';
558 const _SCOPE_ATTR = 'polymer-scope'; 447 const _SCOPE_ATTR = 'polymer-scope';
559 const _STYLE_SCOPE_ATTRIBUTE = 'element'; 448 const _STYLE_SCOPE_ATTRIBUTE = 'element';
560 const _STYLE_CONTROLLER_SCOPE = 'controller'; 449 const _STYLE_CONTROLLER_SCOPE = 'controller';
561 450
562 String _cssTextFromSheet(LinkElement sheet) { 451 String _cssTextFromSheet(LinkElement sheet) {
563 if (sheet == null) return ''; 452 if (sheet == null) return '';
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 516
628 // Dart note: we need this function because we have additional renames JS does 517 // Dart note: we need this function because we have additional renames JS does
629 // not have. The JS renames are simply case differences, whereas we have ones 518 // not have. The JS renames are simply case differences, whereas we have ones
630 // like doubleclick -> dblclick and stripping the webkit prefix. 519 // like doubleclick -> dblclick and stripping the webkit prefix.
631 String _eventNameFromType(String eventType) { 520 String _eventNameFromType(String eventType) {
632 final result = _reverseEventTranslations[eventType]; 521 final result = _reverseEventTranslations[eventType];
633 return result != null ? result : eventType; 522 return result != null ? result : eventType;
634 } 523 }
635 524
636 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); 525 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,');
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/boot.dart ('k') | pkg/polymer/lib/src/instance.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698