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)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 9 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
10 $!MEMBERS | 10 $!MEMBERS |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 * This custom element can also be instantiated via HTML using the syntax | 346 * This custom element can also be instantiated via HTML using the syntax |
347 * `<input is="x-bar"></input>` | 347 * `<input is="x-bar"></input>` |
348 * | 348 * |
349 */ | 349 */ |
350 void registerElement(String tag, Type customElementClass, | 350 void registerElement(String tag, Type customElementClass, |
351 {String extendsTag}) { | 351 {String extendsTag}) { |
352 $if DART2JS | 352 $if DART2JS |
353 _registerCustomElement(JS('', 'window'), this, tag, customElementClass, | 353 _registerCustomElement(JS('', 'window'), this, tag, customElementClass, |
354 extendsTag); | 354 extendsTag); |
355 $else | 355 $else |
356 // TODO(terry): Need to handle the extendsTag. | |
357 | |
358 // Figure out which DOM class is being extended from the user's Dart class. | 356 // Figure out which DOM class is being extended from the user's Dart class. |
359 var classMirror = reflectClass(customElementClass); | 357 var classMirror = reflectClass(customElementClass); |
360 | 358 |
361 var locationUri = classMirror.location.sourceUri.toString(); | 359 var locationUri = classMirror.location.sourceUri.toString(); |
362 if (locationUri == 'dart:html' || locationUri == 'dart:svg') { | 360 if (locationUri == 'dart:html' || locationUri == 'dart:svg') { |
363 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n existing dart:html or dart:svg type."); | 361 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n existing dart:html or dart:svg type."); |
364 } | 362 } |
365 | 363 |
366 if (classMirror.isAbstract) { | 364 if (classMirror.isAbstract) { |
367 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n abstract class."); | 365 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n abstract class."); |
(...skipping 13 matching lines...) Expand all Loading... |
381 // var myProto = Object.create(HTMLElement.prototype); | 379 // var myProto = Object.create(HTMLElement.prototype); |
382 // var myElement = document.registerElement('x-foo', {prototype: myPro
to}); | 380 // var myElement = document.registerElement('x-foo', {prototype: myPro
to}); |
383 var baseElement = js.JsNative.getProperty(js.context, jsClassName); | 381 var baseElement = js.JsNative.getProperty(js.context, jsClassName); |
384 if (baseElement == null) { | 382 if (baseElement == null) { |
385 // Couldn't find the HTML element so use a generic one. | 383 // Couldn't find the HTML element so use a generic one. |
386 baseElement = js.JsNative.getProperty(js.context, 'HTMLElement'); | 384 baseElement = js.JsNative.getProperty(js.context, 'HTMLElement'); |
387 } | 385 } |
388 var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context,
'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]); | 386 var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context,
'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]); |
389 | 387 |
390 // Remember for any upgrading done in wrap_jso. | 388 // Remember for any upgrading done in wrap_jso. |
391 _addCustomElementType(tag, customElementClass); | 389 _addCustomElementType(tag, customElementClass, extendsTag); |
392 | 390 |
393 // TODO(terry): Hack to stop recursion re-creating custom element when the | 391 // TODO(terry): Hack to stop recursion re-creating custom element when the |
394 // created() constructor of the custom element does e.g., | 392 // created() constructor of the custom element does e.g., |
395 // | 393 // |
396 // MyElement.created() : super.created() { | 394 // MyElement.created() : super.created() { |
397 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>"; | 395 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>"; |
398 // } | 396 // } |
399 // | 397 // |
400 // sanitizing causes custom element to created recursively | 398 // sanitizing causes custom element to created recursively |
401 // until stack overflow. | 399 // until stack overflow. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 /// parameter must be provided. | 495 /// parameter must be provided. |
498 @Experimental() | 496 @Experimental() |
499 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | 497 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { |
500 $if DART2JS | 498 $if DART2JS |
501 return new _JSElementUpgrader(this, type, extendsTag); | 499 return new _JSElementUpgrader(this, type, extendsTag); |
502 $else | 500 $else |
503 return new _VMElementUpgrader(this, type, extendsTag); | 501 return new _VMElementUpgrader(this, type, extendsTag); |
504 $endif | 502 $endif |
505 } | 503 } |
506 } | 504 } |
OLD | NEW |