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

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

Issue 22642002: 'extends Element' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « tests/html/html.status ('k') | tools/dom/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of html;
blois 2013/08/09 16:06:23 should be dart.dom.html
sra1 2013/08/12 23:31:26 Done.
6
7
8 /*
9 var proto = Object.create(HTMLElement.prototype, {
10 createdCallback: {
11 get: function() {
12 window.console.log('here');
13 }
14 }
15 });
16 document.register('x-foo', {
17 prototype: proto
18 });
19
20 var e = document.createElement('x-foo');
21
22 */
23
24 callOnCreated(receiver) {
blois 2013/08/09 16:06:23 Can these either be private or not top-level?
sra1 2013/08/12 23:31:26 Done.
25 return receiver.onCreated();
26 }
27
28 makeCreatedCallbackMethod() {
29 return JS('',
30 '''((function(invokeCallback) {
blois 2013/08/09 16:06:23 Is this outer function closure needed?
sra1 2013/08/12 23:31:26 Yes, see https://code.google.com/p/dart/source/bro
31 return function() {
32 return invokeCallback(this);
33 };
34 })(#))''',
35 convertDartClosureToJS(callOnCreated, 1));
36 }
37
38 void registerCustomElement(context, document, String tag, Type type) {
39 var interceptorClass = findInterceptorConstructorForType(type);
40 if (interceptorClass == null) {
41 throw new ArgumentError(type);
42 }
43
44 String baseClassName = findDispatchTagForInterceptorClass(interceptorClass);
45 if (baseClassName == null) {
46 throw new ArgumentError(type);
47 }
48 if (baseClassName == 'Element') baseClassName = 'HTMLElement';
49
50 var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
51 if (JS('bool', "typeof(#) != 'function'", baseConstructor)) {
52 throw new ArgumentError(type);
53 }
54
55 var properties = JS('=Object', '{}');
56
57 var jsCreatedCallback = makeCreatedCallbackMethod();
58
59 JS('void', '#.createdCallback = #', properties,
60 JS('=Object', '{value: #}', jsCreatedCallback));
61
62 var baseProto = JS('=Object', '#.prototype', baseConstructor);
63 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties);
64
65 var interceptor = JS('=Object', '#.prototype', interceptorClass);
66
67 setNativeSubclassDispatchRecord(proto, interceptor);
68
69
70 JS('void', '#.register(#, #)',
71 document, tag, JS('', '{prototype: #}', proto));
72
73 print('Registered $type');
blois 2013/08/09 16:06:23 Debugging
sra1 2013/08/12 23:31:26 Done.
74 }
OLDNEW
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698