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

Side by Side Diff: tools/dom/src/dart2js_CustomElementSupport.dart

Issue 140853005: update custom elements and shadow dom (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
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 dart.dom.html; 5 part of dart.dom.html;
6 6
7 _callConstructor(constructor, interceptor) { 7 _callConstructor(constructor, interceptor) {
8 return (receiver) { 8 return (receiver) {
9 setNativeSubclassDispatchRecord(receiver, interceptor); 9 setNativeSubclassDispatchRecord(receiver, interceptor);
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Function follows the same pattern as the following JavaScript code for 48 // Function follows the same pattern as the following JavaScript code for
49 // registering a custom element. 49 // registering a custom element.
50 // 50 //
51 // var proto = Object.create(HTMLElement.prototype, { 51 // var proto = Object.create(HTMLElement.prototype, {
52 // createdCallback: { 52 // createdCallback: {
53 // value: function() { 53 // value: function() {
54 // window.console.log('here'); 54 // window.console.log('here');
55 // } 55 // }
56 // } 56 // }
57 // }); 57 // });
58 // document.register('x-foo', { prototype: proto }); 58 // document.registerElement('x-foo', { prototype: proto });
59 // ... 59 // ...
60 // var e = document.createElement('x-foo'); 60 // var e = document.createElement('x-foo');
61 61
62 var interceptorClass = findInterceptorConstructorForType(type); 62 var interceptorClass = findInterceptorConstructorForType(type);
63 if (interceptorClass == null) { 63 if (interceptorClass == null) {
64 throw new ArgumentError(type); 64 throw new ArgumentError(type);
65 } 65 }
66 66
67 var interceptor = JS('=Object', '#.prototype', interceptorClass); 67 var interceptor = JS('=Object', '#.prototype', interceptorClass);
68 68
(...skipping 23 matching lines...) Expand all
92 } 92 }
93 } 93 }
94 94
95 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); 95 var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
96 96
97 var properties = JS('=Object', '{}'); 97 var properties = JS('=Object', '{}');
98 98
99 JS('void', '#.createdCallback = #', properties, 99 JS('void', '#.createdCallback = #', properties,
100 JS('=Object', '{value: #}', 100 JS('=Object', '{value: #}',
101 _makeCallbackMethod(_callConstructor(constructor, interceptor)))); 101 _makeCallbackMethod(_callConstructor(constructor, interceptor))));
102 JS('void', '#.enteredViewCallback = #', properties, 102 JS('void', '#.attachedCallback = #', properties,
blois 2014/01/28 00:15:27 Can keep both enteredView and attachedCallback unt
Jennifer Messerly 2014/01/29 20:52:37 chatted in person, I think with registerElement we
103 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); 103 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView)));
104 JS('void', '#.leftViewCallback = #', properties, 104 JS('void', '#.detachedCallback = #', properties,
105 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); 105 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView)));
106 JS('void', '#.attributeChangedCallback = #', properties, 106 JS('void', '#.attributeChangedCallback = #', properties,
107 JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged))); 107 JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged)));
108 108
109 var baseProto = JS('=Object', '#.prototype', baseConstructor); 109 var baseProto = JS('=Object', '#.prototype', baseConstructor);
110 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); 110 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties);
111 111
112 setNativeSubclassDispatchRecord(proto, interceptor); 112 setNativeSubclassDispatchRecord(proto, interceptor);
113 113
114 var options = JS('=Object', '{prototype: #}', proto); 114 var options = JS('=Object', '{prototype: #}', proto);
115 115
116 if (extendsTagName != null) { 116 if (extendsTagName != null) {
117 JS('=Object', '#.extends = #', options, extendsTagName); 117 JS('=Object', '#.extends = #', options, extendsTagName);
118 } 118 }
119 119
120 JS('void', '#.register(#, #)', document, tag, options); 120 JS('void', '#.registerElement(#, #)', document, tag, options);
121 } 121 }
122 122
123 //// Called by Element.created to do validation & initialization. 123 //// Called by Element.created to do validation & initialization.
124 void _initializeCustomElement(Element e) { 124 void _initializeCustomElement(Element e) {
125 // TODO(blois): Add validation that this is only in response to an upgrade. 125 // TODO(blois): Add validation that this is only in response to an upgrade.
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698