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

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

Issue 17917002: Continue updating MDV. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 5 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 Element _templateInstanceRef; 669 Element _templateInstanceRef;
670 670
671 // Note: only used if `this is! TemplateElement` 671 // Note: only used if `this is! TemplateElement`
672 $if DART2JS 672 $if DART2JS
673 @Creates('Null') // Set from Dart code; does not instantiate a native type. 673 @Creates('Null') // Set from Dart code; does not instantiate a native type.
674 $endif 674 $endif
675 DocumentFragment _templateContent; 675 DocumentFragment _templateContent;
676 676
677 bool _templateIsDecorated; 677 bool _templateIsDecorated;
678 678
679
679 /** 680 /**
680 * Gets the template this node refers to. 681 * Gets the template this node refers to.
681 * This is only supported if [isTemplate] is true. 682 * This is only supported if [isTemplate] is true.
682 */ 683 */
683 @Experimental 684 @Experimental
684 Element get ref { 685 Element get ref {
685 _ensureTemplate(); 686 _ensureTemplate();
686 687
687 Element ref = null; 688 Element ref = null;
688 var refId = attributes['ref']; 689 var refId = attributes['ref'];
689 if (refId != null) { 690 if (refId != null) {
690 ref = document.getElementById(refId); 691 var treeScope = this;
692 while (treeScope.parentNode != null) {
693 treeScope = treeScope.parentNode;
694 }
695
696 // Note: JS code tests that getElementById is present. We can't do that
697 // easily, so instead check for the types known to implement it.
698 if (treeScope is Document ||
699 treeScope is ShadowRoot ||
700 treeScope is svg.SvgSvgElement) {
701
702 ref = treeScope.getElementById(refId);
703 }
691 } 704 }
692 705
693 return ref != null ? ref : _templateInstanceRef; 706 return ref != null ? ref : _templateInstanceRef;
694 } 707 }
695 708
696 /** 709 /**
697 * Gets the content of this template. 710 * Gets the content of this template.
698 * This is only supported if [isTemplate] is true. 711 * This is only supported if [isTemplate] is true.
699 */ 712 */
700 @Experimental 713 @Experimental
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 'colgroup': null, 746 'colgroup': null,
734 'tbody': null, 747 'tbody': null,
735 'td': null, 748 'td': null,
736 'tfoot': null, 749 'tfoot': null,
737 'th': null, 750 'th': null,
738 'thead': null, 751 'thead': null,
739 'tr': null, 752 'tr': null,
740 }; 753 };
741 754
742 bool get _isAttributeTemplate => attributes.containsKey('template') && 755 bool get _isAttributeTemplate => attributes.containsKey('template') &&
743 (localName == 'option' || _TABLE_TAGS.containsKey(localName)); 756 (localName == 'option' || localName == 'optgroup' ||
757 _TABLE_TAGS.containsKey(localName));
744 758
745 /** 759 /**
746 * Returns true if this node is a template. 760 * Returns true if this node is a template.
747 * 761 *
748 * A node is a template if [tagName] is TEMPLATE, or the node has the 762 * A node is a template if [tagName] is TEMPLATE, or the node has the
749 * 'template' attribute and this tag supports attribute form for backwards 763 * 'template' attribute and this tag supports attribute form for backwards
750 * compatibility with existing HTML parsers. The nodes that can use attribute 764 * compatibility with existing HTML parsers. The nodes that can use attribute
751 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP 765 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP
752 * and COL) and OPTION. 766 * and COL), OPTION, and OPTGROUP.
753 */ 767 */
754 // TODO(jmesserly): this is not a public MDV API, but it seems like a useful 768 // TODO(jmesserly): this is not a public MDV API, but it seems like a useful
755 // place to document which tags our polyfill considers to be templates. 769 // place to document which tags our polyfill considers to be templates.
756 // Otherwise I'd be repeating it in several other places. 770 // Otherwise I'd be repeating it in several other places.
757 // See if we can replace this with a TemplateMixin. 771 // See if we can replace this with a TemplateMixin.
758 @Experimental 772 @Experimental
759 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate; 773 bool get isTemplate => tagName == 'TEMPLATE' || _isAttributeTemplate;
760 774
761 void _ensureTemplate() { 775 void _ensureTemplate() {
762 if (!isTemplate) { 776 if (!isTemplate) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 const ScrollAlignment._internal(this._value); 919 const ScrollAlignment._internal(this._value);
906 toString() => 'ScrollAlignment.$_value'; 920 toString() => 'ScrollAlignment.$_value';
907 921
908 /// Attempt to align the element to the top of the scrollable area. 922 /// Attempt to align the element to the top of the scrollable area.
909 static const TOP = const ScrollAlignment._internal('TOP'); 923 static const TOP = const ScrollAlignment._internal('TOP');
910 /// Attempt to center the element in the scrollable area. 924 /// Attempt to center the element in the scrollable area.
911 static const CENTER = const ScrollAlignment._internal('CENTER'); 925 static const CENTER = const ScrollAlignment._internal('CENTER');
912 /// Attempt to align the element to the bottom of the scrollable area. 926 /// Attempt to align the element to the bottom of the scrollable area.
913 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 927 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
914 } 928 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698