OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // WARNING: Do not edit - generated code. | 5 // WARNING: Do not edit - generated code. |
6 | 6 |
7 part of $LIBRARYNAME; | 7 part of $LIBRARYNAME; |
8 | 8 |
9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
10 $!MEMBERS | 10 $!MEMBERS |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 * | 237 * |
238 * main() { | 238 * main() { |
239 * document.register('x-bar', BarElement); | 239 * document.register('x-bar', BarElement); |
240 * var myBar = new Element.tag('input', 'x-bar'); | 240 * var myBar = new Element.tag('input', 'x-bar'); |
241 * // prints 'BarElement created!' to the console. | 241 * // prints 'BarElement created!' to the console. |
242 * } | 242 * } |
243 * | 243 * |
244 * This custom element can also be instantiated via HTML using the syntax | 244 * This custom element can also be instantiated via HTML using the syntax |
245 * `<input is="x-bar"></input>` | 245 * `<input is="x-bar"></input>` |
246 * | 246 * |
247 * The [nativeTagName] parameter is needed by platforms without native support | |
248 * when subclassing a native type other than: | |
249 * | |
250 * * HtmlElement | |
251 * * SvgElement | |
252 * * AnchorElement | |
253 * * AudioElement | |
254 * * ButtonElement | |
255 * * CanvasElement | |
256 * * DivElement | |
257 * * ImageElement | |
258 * * InputElement | |
259 * * LIElement | |
260 * * LabelElement | |
261 * * MenuElement | |
262 * * MeterElement | |
263 * * OListElement | |
264 * * OptionElement | |
265 * * OutputElement | |
266 * * ParagraphElement | |
267 * * PreElement | |
268 * * ProgressElement | |
269 * * SelectElement | |
270 * * SpanElement | |
271 * * UListElement | |
272 * * VideoElement | |
273 */ | 247 */ |
274 $if DART2JS | 248 $if DART2JS |
275 void register(String tag, Type customElementClass, {String extendsTag}) { | 249 void register(String tag, Type customElementClass, {String extendsTag}) { |
276 _registerCustomElement(JS('', 'window'), this, tag, customElementClass, | 250 _registerCustomElement(JS('', 'window'), this, tag, customElementClass, |
277 extendsTag); | 251 extendsTag); |
278 } | 252 } |
279 $else | 253 $else |
280 void register(String tag, Type customElementClass, {String extendsTag}) { | 254 void register(String tag, Type customElementClass, {String extendsTag}) { |
281 _Utils.register(this, tag, customElementClass, extendsTag); | 255 _Utils.register(this, tag, customElementClass, extendsTag); |
282 } | 256 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 return 'webkitvisibilitychange'; | 288 return 'webkitvisibilitychange'; |
315 $endif | 289 $endif |
316 } | 290 } |
317 | 291 |
318 @SupportedBrowser(SupportedBrowser.CHROME) | 292 @SupportedBrowser(SupportedBrowser.CHROME) |
319 @SupportedBrowser(SupportedBrowser.FIREFOX) | 293 @SupportedBrowser(SupportedBrowser.FIREFOX) |
320 @SupportedBrowser(SupportedBrowser.IE, '10') | 294 @SupportedBrowser(SupportedBrowser.IE, '10') |
321 @Experimental() | 295 @Experimental() |
322 Stream<Event> get onVisibilityChange => | 296 Stream<Event> get onVisibilityChange => |
323 visibilityChangeEvent.forTarget(this); | 297 visibilityChangeEvent.forTarget(this); |
298 | |
299 /// Creates an element upgrader which can be used to change the Dart wrapper | |
300 /// type for elements. | |
301 /// | |
302 /// The type specified must be a subclass of HtmlElement, when an element is | |
303 /// upgraded then the created constructor will be invoked on that element. | |
304 /// | |
305 /// If the type is not a direct subclass of HtmlElement then the extendsTag | |
306 /// parameter must be provided. | |
307 @Experimental() | |
308 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | |
Jennifer Messerly
2014/03/07 00:00:49
Maybe a TODO: we can move this to the registration
| |
309 $if DART2JS | |
310 return new _JSElementUpgrader(this, type, extendsTag); | |
311 $else | |
312 return new _VMElementUpgrader(this, type, extendsTag); | |
313 $endif | |
314 } | |
324 } | 315 } |
316 | |
317 /// A utility for changing the Dart wrapper type for elements. | |
318 abstract class ElementUpgrader { | |
319 /// Upgrade the specified element to be of the Dart type this was created for. | |
320 /// | |
321 /// After upgrading the element passed in is invalid and the returned value | |
322 /// should be used instead. | |
323 Element upgrade(Element element); | |
324 } | |
OLD | NEW |