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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. | 356 // TODO(terry): Need to handle the extendsTag. |
357 | 357 |
358 // Figure out which DOM class is being extended from the user's Dart class. | 358 // Figure out which DOM class is being extended from the user's Dart class. |
359 var classMirror = reflectClass(customElementClass); | 359 var classMirror = reflectClass(customElementClass); |
| 360 |
| 361 var locationUri = classMirror.location.sourceUri.toString(); |
| 362 if (locationUri == 'dart:html' || locationUri == 'dart:svg') { |
| 363 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n existing dart:html or dart:svg type."); |
| 364 } |
| 365 |
| 366 if (classMirror.isAbstract) { |
| 367 throw new DomException.jsInterop("HierarchyRequestError: Cannot register a
n abstract class."); |
| 368 } |
| 369 |
360 var jsClassName = _getJSClassName(classMirror); | 370 var jsClassName = _getJSClassName(classMirror); |
361 if (jsClassName == null) { | 371 if (jsClassName == null) { |
362 // Only components derived from HTML* can be extended. | 372 // Only components derived from HTML* can be extended. |
363 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element
s can be customized."); | 373 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element
s can be customized."); |
364 } | 374 } |
365 | 375 |
366 if (_hasCreatedConstructor(classMirror)) { | 376 if (_hasCreatedConstructor(classMirror)) { |
367 // Start the hookup the JS way create an <x-foo> element that extends the | 377 // Start the hookup the JS way create an <x-foo> element that extends the |
368 // <x-base> custom element. Inherit its prototype and signal what tag is | 378 // <x-base> custom element. Inherit its prototype and signal what tag is |
369 // inherited: | 379 // inherited: |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 /// parameter must be provided. | 497 /// parameter must be provided. |
488 @Experimental() | 498 @Experimental() |
489 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | 499 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { |
490 $if DART2JS | 500 $if DART2JS |
491 return new _JSElementUpgrader(this, type, extendsTag); | 501 return new _JSElementUpgrader(this, type, extendsTag); |
492 $else | 502 $else |
493 return new _VMElementUpgrader(this, type, extendsTag); | 503 return new _VMElementUpgrader(this, type, extendsTag); |
494 $endif | 504 $endif |
495 } | 505 } |
496 } | 506 } |
OLD | NEW |