| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // Only components derived from HTML* can be extended. | 387 // Only components derived from HTML* can be extended. |
| 388 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element
s can be customized."); | 388 throw new DomException.jsInterop("HierarchyRequestError: Only HTML element
s can be customized."); |
| 389 } | 389 } |
| 390 | 390 |
| 391 var customClassType = _getDartHtmlClassName(classMirror); | 391 var customClassType = _getDartHtmlClassName(classMirror); |
| 392 | 392 |
| 393 if (extendsTag != null) { | 393 if (extendsTag != null) { |
| 394 var nativeElement = document.createElement(extendsTag); | 394 var nativeElement = document.createElement(extendsTag); |
| 395 | 395 |
| 396 // Trying to extend a native element is it the Dart class consistent with
the | 396 // Trying to extend a native element is it the Dart class consistent with
the |
| 397 // extendsTag? | 397 // extendsTag? |
| 398 if (nativeElement.runtimeType != customClassType.reflectedType) { | 398 if (nativeElement.runtimeType != customClassType.reflectedType) { |
| 399 var nativeElementClassMirror = reflectClass(nativeElement.runtimeType); | 399 var nativeElementClassMirror = reflectClass(nativeElement.runtimeType); |
| 400 var customClassNativeElement = MirrorSystem.getName(customClassType.simp
leName); | 400 var customClassNativeElement = MirrorSystem.getName(customClassType.simp
leName); |
| 401 var extendsNativeElement = MirrorSystem.getName(nativeElementClassMirror
.simpleName); | 401 var extendsNativeElement = MirrorSystem.getName(nativeElementClassMirror
.simpleName); |
| 402 throw new DomException.jsInterop("HierarchyRequestError: Custom class ty
pe ($customClassNativeElement) and extendsTag class ($extendsNativeElement) don'
t match ."); | 402 throw new DomException.jsInterop("HierarchyRequestError: Custom class ty
pe ($customClassNativeElement) and extendsTag class ($extendsNativeElement) don'
t match ."); |
| 403 } | 403 } |
| 404 } else if (customClassType.reflectedType != HtmlElement && customClassType.r
eflectedType != svg.SvgElement) { | 404 } else if (customClassType.reflectedType != HtmlElement && customClassType.r
eflectedType != svg.SvgElement) { |
| 405 var customClassName = MirrorSystem.getName(classMirror.simpleName); | 405 var customClassName = MirrorSystem.getName(classMirror.simpleName); |
| 406 var customClassElement = MirrorSystem.getName(customClassType.simpleName); | 406 var customClassElement = MirrorSystem.getName(customClassType.simpleName); |
| 407 throw new DomException.jsInterop("HierarchyRequestError: Custom element $c
ustomClassName is a native $customClassElement should be derived from HtmlElemen
t or SvgElement."); | 407 throw new DomException.jsInterop("HierarchyRequestError: Custom element $c
ustomClassName is a native $customClassElement should be derived from HtmlElemen
t or SvgElement."); |
| 408 } | 408 } |
| 409 | 409 |
| 410 if (_hasCreatedConstructor(classMirror)) { | 410 if (_hasCreatedConstructor(classMirror)) { |
| 411 // Start the hookup the JS way create an <x-foo> element that extends the | 411 // Start the hookup the JS way create an <x-foo> element that extends the |
| 412 // <x-base> custom element. Inherit its prototype and signal what tag is | 412 // <x-base> custom element. Inherit its prototype and signal what tag is |
| 413 // inherited: | 413 // inherited: |
| 414 // | 414 // |
| 415 // var myProto = Object.create(HTMLElement.prototype); | 415 // var myProto = Object.create(HTMLElement.prototype); |
| 416 // var myElement = document.registerElement('x-foo', {prototype: myPro
to}); | 416 // var myElement = document.registerElement('x-foo', {prototype: myPro
to}); |
| 417 var baseElement = js.JsNative.getProperty(js.context, jsClassName); | 417 var baseElement = js.JsNative.getProperty(js.context, jsClassName); |
| 418 if (baseElement == null) { | 418 if (baseElement == null) { |
| 419 // Couldn't find the HTML element so use a generic one. | 419 // Couldn't find the HTML element so use a generic one. |
| 420 baseElement = js.JsNative.getProperty(js.context, 'HTMLElement'); | 420 baseElement = js.JsNative.getProperty(js.context, 'HTMLElement'); |
| 421 } | 421 } |
| 422 var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context,
'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]); | 422 var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context,
'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]); |
| 423 | 423 |
| 424 // Remember for any upgrading done in wrap_jso. | 424 // Remember for any upgrading done in wrap_jso. |
| 425 _addCustomElementType(tag, customElementClass, extendsTag); | 425 addCustomElementType(tag, customElementClass, extendsTag); |
| 426 | 426 |
| 427 // TODO(terry): Hack to stop recursion re-creating custom element when the | 427 // TODO(terry): Hack to stop recursion re-creating custom element when the |
| 428 // created() constructor of the custom element does e.g., | 428 // created() constructor of the custom element does e.g., |
| 429 // | 429 // |
| 430 // MyElement.created() : super.created() { | 430 // MyElement.created() : super.created() { |
| 431 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>"; | 431 // this.innerHtml = "<b>I'm an x-foo-with-markup!</b>"; |
| 432 // } | 432 // } |
| 433 // | 433 // |
| 434 // sanitizing causes custom element to created recursively | 434 // sanitizing causes custom element to created recursively |
| 435 // until stack overflow. | 435 // until stack overflow. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 /// parameter must be provided. | 548 /// parameter must be provided. |
| 549 @Experimental() | 549 @Experimental() |
| 550 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | 550 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { |
| 551 $if DART2JS | 551 $if DART2JS |
| 552 return new _JSElementUpgrader(this, type, extendsTag); | 552 return new _JSElementUpgrader(this, type, extendsTag); |
| 553 $else | 553 $else |
| 554 return new _VMElementUpgrader(this, type, extendsTag); | 554 return new _VMElementUpgrader(this, type, extendsTag); |
| 555 $endif | 555 $endif |
| 556 } | 556 } |
| 557 } | 557 } |
| OLD | NEW |