Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 14795005: Add support for custom elements to MDV (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 class _ChildrenElementList extends ListBase<Element> { 7 class _ChildrenElementList extends ListBase<Element> {
8 // Raw Element. 8 // Raw Element.
9 final Element _element; 9 final Element _element;
10 final HtmlCollection _childElements; 10 final HtmlCollection _childElements;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return e is Element && !(e is UnknownElement); 417 return e is Element && !(e is UnknownElement);
418 } 418 }
419 419
420 /** 420 /**
421 * Called by the DOM when this element has been instantiated. 421 * Called by the DOM when this element has been instantiated.
422 */ 422 */
423 @Experimental 423 @Experimental
424 void onCreated() {} 424 void onCreated() {}
425 425
426 // Hooks to support custom WebComponents. 426 // Hooks to support custom WebComponents.
427
428 $if DART2JS
429 @Creates('Null') // Set from Dart code; does not instantiate a native type.
430 $endif
431 Element _xtag;
432
427 /** 433 /**
428 * Experimental support for [web components][wc]. This field stores a 434 * Experimental support for [web components][wc]. This field stores a
429 * reference to the component implementation. It was inspired by Mozilla's 435 * reference to the component implementation. It was inspired by Mozilla's
430 * [x-tags][] project. Please note: in the future it may be possible to 436 * [x-tags][] project. Please note: in the future it may be possible to
431 * `extend Element` from your class, in which case this field will be 437 * `extend Element` from your class, in which case this field will be
432 * deprecated and will simply return this [Element] object. 438 * deprecated.
439 *
440 * If xtag has not been set, it will simply return `this` [Element].
433 * 441 *
434 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html 442 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
435 * [x-tags]: http://x-tags.org/ 443 * [x-tags]: http://x-tags.org/
436 */ 444 */
437 $if DART2JS 445 Element get xtag => _xtag != null ? _xtag : this;
438 @Creates('Null') // Set from Dart code; does not instantiate a native type. 446
439 $endif 447 void set xtag(Element value) {
440 var xtag; 448 _xtag = value;
449 }
441 450
442 /** 451 /**
443 * Scrolls this element into view. 452 * Scrolls this element into view.
444 * 453 *
445 * Only one of of the alignment options may be specified at a time. 454 * Only one of of the alignment options may be specified at a time.
446 * 455 *
447 * If no options are specified then this will attempt to scroll the minimum 456 * If no options are specified then this will attempt to scroll the minimum
448 * amount needed to bring the element into view. 457 * amount needed to bring the element into view.
449 * 458 *
450 * Note that alignCenter is currently only supported on WebKit platforms. If 459 * Note that alignCenter is currently only supported on WebKit platforms. If
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 676
668 // TODO(jmesserly): this is static to work around http://dartbug.com/10166 677 // TODO(jmesserly): this is static to work around http://dartbug.com/10166
669 // Similar issue for unbind/unbindAll below. 678 // Similar issue for unbind/unbindAll below.
670 static void _bindElement(Element self, String name, model, String path) { 679 static void _bindElement(Element self, String name, model, String path) {
671 if (self._bindTemplate(name, model, path)) return; 680 if (self._bindTemplate(name, model, path)) return;
672 681
673 if (self._attributeBindings == null) { 682 if (self._attributeBindings == null) {
674 self._attributeBindings = new Map<String, StreamSubscription>(); 683 self._attributeBindings = new Map<String, StreamSubscription>();
675 } 684 }
676 685
677 self.attributes.remove(name); 686 self.xtag.attributes.remove(name);
678 687
679 var changed; 688 var changed;
680 if (name.endsWith('?')) { 689 if (name.endsWith('?')) {
681 name = name.substring(0, name.length - 1); 690 name = name.substring(0, name.length - 1);
682 691
683 changed = (value) { 692 changed = (value) {
684 if (_templateBooleanConversion(value)) { 693 if (_templateBooleanConversion(value)) {
685 self.attributes[name] = ''; 694 self.xtag.attributes[name] = '';
686 } else { 695 } else {
687 self.attributes.remove(name); 696 self.xtag.attributes.remove(name);
688 } 697 }
689 }; 698 };
690 } else { 699 } else {
691 changed = (value) { 700 changed = (value) {
692 // TODO(jmesserly): escape value if needed to protect against XSS. 701 // TODO(jmesserly): escape value if needed to protect against XSS.
693 // See https://github.com/toolkitchen/mdv/issues/58 702 // See https://github.com/toolkitchen/mdv/issues/58
694 self.attributes[name] = value == null ? '' : '$value'; 703 self.xtag.attributes[name] = value == null ? '' : '$value';
695 }; 704 };
696 } 705 }
697 706
698 self.unbind(name); 707 self.unbind(name);
699 708
700 self._attributeBindings[name] = 709 self._attributeBindings[name] =
701 new PathObserver(model, path).bindSync(changed); 710 new PathObserver(model, path).bindSync(changed);
702 } 711 }
703 712
704 @Experimental 713 @Experimental
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 const ScrollAlignment._internal(this._value); 1032 const ScrollAlignment._internal(this._value);
1024 toString() => 'ScrollAlignment.$_value'; 1033 toString() => 'ScrollAlignment.$_value';
1025 1034
1026 /// Attempt to align the element to the top of the scrollable area. 1035 /// Attempt to align the element to the top of the scrollable area.
1027 static const TOP = const ScrollAlignment._internal('TOP'); 1036 static const TOP = const ScrollAlignment._internal('TOP');
1028 /// Attempt to center the element in the scrollable area. 1037 /// Attempt to center the element in the scrollable area.
1029 static const CENTER = const ScrollAlignment._internal('CENTER'); 1038 static const CENTER = const ScrollAlignment._internal('CENTER');
1030 /// Attempt to align the element to the bottom of the scrollable area. 1039 /// Attempt to align the element to the bottom of the scrollable area.
1031 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1040 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1032 } 1041 }
OLDNEW
« tools/dom/src/TemplateBindings.dart ('K') | « tools/dom/src/TemplateBindings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698