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 dart.dom.html; | 5 part of dart.dom.html; |
6 | 6 |
7 _callConstructor(constructor) { | 7 _callConstructor(constructor) { |
8 return (receiver) { | 8 return (receiver) { |
9 return JS('', '#(#)', constructor, receiver); | 9 return JS('', '#(#)', constructor, receiver); |
10 }; | 10 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 // Workaround for 13190- use an article element to ensure that HTMLElement's | 70 // Workaround for 13190- use an article element to ensure that HTMLElement's |
71 // interceptor is resolved correctly. | 71 // interceptor is resolved correctly. |
72 getNativeInterceptor(new Element.tag('article')); | 72 getNativeInterceptor(new Element.tag('article')); |
73 | 73 |
74 String baseClassName = findDispatchTagForInterceptorClass(interceptorClass); | 74 String baseClassName = findDispatchTagForInterceptorClass(interceptorClass); |
75 if (baseClassName == null) { | 75 if (baseClassName == null) { |
76 throw new ArgumentError(type); | 76 throw new ArgumentError(type); |
77 } | 77 } |
78 if (baseClassName == 'Element') baseClassName = 'HTMLElement'; | 78 |
| 79 if (extendsTagName == null) { |
| 80 if (baseClassName != 'HTMLElement') { |
| 81 throw new UnsupportedError('Class must provide extendsTag if base ' |
| 82 'native class is not HTMLElement'); |
| 83 } |
| 84 } else { |
| 85 if (!JS('bool', '(#.createElement(#) instanceof window[#])', |
| 86 document, extendsTagName, baseClassName)) { |
| 87 throw new UnsupportedError('extendsTag does not match base native class'); |
| 88 } |
| 89 } |
79 | 90 |
80 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); | 91 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); |
81 | 92 |
82 var properties = JS('=Object', '{}'); | 93 var properties = JS('=Object', '{}'); |
83 | 94 |
84 JS('void', '#.createdCallback = #', properties, | 95 JS('void', '#.createdCallback = #', properties, |
85 JS('=Object', '{value: #}', | 96 JS('=Object', '{value: #}', |
86 _makeCallbackMethod(_callConstructor(constructor)))); | 97 _makeCallbackMethod(_callConstructor(constructor)))); |
87 JS('void', '#.enteredViewCallback = #', properties, | 98 JS('void', '#.enteredViewCallback = #', properties, |
88 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | 99 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); |
(...skipping 23 matching lines...) Expand all Loading... |
112 } | 123 } |
113 } | 124 } |
114 | 125 |
115 JS('void', '#.register(#, #)', document, tag, options); | 126 JS('void', '#.register(#, #)', document, tag, options); |
116 } | 127 } |
117 | 128 |
118 //// Called by Element.created to do validation & initialization. | 129 //// Called by Element.created to do validation & initialization. |
119 void _initializeCustomElement(Element e) { | 130 void _initializeCustomElement(Element e) { |
120 // TODO(blois): Add validation that this is only in response to an upgrade. | 131 // TODO(blois): Add validation that this is only in response to an upgrade. |
121 } | 132 } |
OLD | NEW |