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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
436 // | 436 // |
437 // See https://github.com/dart-lang/sdk/issues/23666 | 437 // See https://github.com/dart-lang/sdk/issues/23666 |
438 int creating = 0; | 438 int creating = 0; |
| 439 |
| 440 // If any JS code is hooked we want to call it too. |
| 441 var oldCreatedCallback = elemProto['createdCallback']; |
| 442 var oldAttributeChangedCallback = elemProto['attributeChangedCallback']; |
| 443 var oldAttachedCallback = elemProto['attachedCallback']; |
| 444 var oldDetachedCallback = elemProto['detachedCallback']; |
| 445 |
439 // TODO(jacobr): warning: | 446 // TODO(jacobr): warning: |
440 elemProto['createdCallback'] = js.JsNative.withThis(($this) { | 447 elemProto['createdCallback'] = js.JsNative.withThis(($this) { |
441 if (_getJSClassName(reflectClass(customElementClass).superclass) != null
&& creating < 2) { | 448 if (_getJSClassName(reflectClass(customElementClass).superclass) != null
&& creating < 2) { |
442 creating++; | 449 creating++; |
443 | 450 |
444 var dartClass; | 451 var dartClass; |
445 try { | 452 try { |
446 if (extendsTag != null) { | 453 if (extendsTag != null) { |
447 // If we're extending a native element then create that element. | 454 // If we're extending a native element then create that element. |
448 // Then upgrade that element to the customElementClass through | 455 // Then upgrade that element to the customElementClass through |
(...skipping 18 matching lines...) Expand all Loading... |
467 throw e; | 474 throw e; |
468 } finally { | 475 } finally { |
469 // Need to remember the Dart class that was created for this custom
so | 476 // Need to remember the Dart class that was created for this custom
so |
470 // return it and setup the blink_jsObject to the $this that we'll be
working | 477 // return it and setup the blink_jsObject to the $this that we'll be
working |
471 // with as we talk to blink. | 478 // with as we talk to blink. |
472 js.setDartHtmlWrapperFor($this, dartClass); | 479 js.setDartHtmlWrapperFor($this, dartClass); |
473 | 480 |
474 creating--; | 481 creating--; |
475 } | 482 } |
476 } | 483 } |
| 484 |
| 485 if (oldCreatedCallback != null) |
| 486 oldCreatedCallback.apply([], thisArg: unwrap_jso($this)); |
477 }); | 487 }); |
478 elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($this,
attrName, oldVal, newVal) { | 488 elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($this,
attrName, oldVal, newVal) { |
479 $this.attributeChanged(attrName, oldVal, newVal); | 489 $this.attributeChanged(attrName, oldVal, newVal); |
| 490 |
| 491 if (oldAttributeChangedCallback != null) |
| 492 oldAttributeChangedCallback.apply([], thisArg: unwrap_jso($this)); |
480 }); | 493 }); |
481 elemProto['attachedCallback'] = new js.JsFunction.withThis(($this) { | 494 elemProto['attachedCallback'] = new js.JsFunction.withThis(($this) { |
482 $this.attached(); | 495 $this.attached(); |
| 496 |
| 497 if (oldAttachedCallback != null) |
| 498 oldAttachedCallback.apply([], thisArg: unwrap_jso($this)); |
483 }); | 499 }); |
484 elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) { | 500 elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) { |
485 $this.detached(); | 501 $this.detached(); |
| 502 |
| 503 if (oldDetachedCallback != null) |
| 504 oldDetachedCallback.apply([], thisArg: unwrap_jso($this)); |
486 }); | 505 }); |
487 // document.registerElement('x-foo', {prototype: elemProto, extends: exten
dsTag}); | 506 // document.registerElement('x-foo', {prototype: elemProto, extends: exten
dsTag}); |
488 var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': exte
ndsTag}); | 507 var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': exte
ndsTag}); |
489 js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'document'), 'r
egisterElement', [tag, jsMap]); | 508 js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'document'), 'r
egisterElement', [tag, jsMap]); |
490 } | 509 } |
491 $endif | 510 $endif |
492 } | 511 } |
493 | 512 |
494 /** *Deprecated*: use [registerElement] instead. */ | 513 /** *Deprecated*: use [registerElement] instead. */ |
495 @deprecated | 514 @deprecated |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 /// parameter must be provided. | 567 /// parameter must be provided. |
549 @Experimental() | 568 @Experimental() |
550 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | 569 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { |
551 $if DART2JS | 570 $if DART2JS |
552 return new _JSElementUpgrader(this, type, extendsTag); | 571 return new _JSElementUpgrader(this, type, extendsTag); |
553 $else | 572 $else |
554 return new _VMElementUpgrader(this, type, extendsTag); | 573 return new _VMElementUpgrader(this, type, extendsTag); |
555 $endif | 574 $endif |
556 } | 575 } |
557 } | 576 } |
OLD | NEW |