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

Side by Side Diff: sdk/lib/html/templates/html/impl/impl_Element.darttemplate

Issue 11679007: Adding support checks for partially supported element types and updating tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 html; 5 part of html;
6 6
7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList implements List { 9 class _ChildrenElementList implements List {
10 // Raw Element. 10 // Raw Element.
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 * [tag] should be a valid HTML tag name. If [tag] is an unknown tag then 378 * [tag] should be a valid HTML tag name. If [tag] is an unknown tag then
379 * this will create an [UnknownElement]. 379 * this will create an [UnknownElement].
380 * 380 *
381 * var divElement = new Element.tag('div'); 381 * var divElement = new Element.tag('div');
382 * print(divElement is DivElement); // 'true' 382 * print(divElement is DivElement); // 'true'
383 * var myElement = new Element.tag('unknownTag'); 383 * var myElement = new Element.tag('unknownTag');
384 * print(myElement is UnknownElement); // 'true' 384 * print(myElement is UnknownElement); // 'true'
385 * 385 *
386 * For standard elements it is more preferable to use the type constructors: 386 * For standard elements it is more preferable to use the type constructors:
387 * var element = new DivElement(); 387 * var element = new DivElement();
388 *
389 * See also:
390 *
391 * * [isTagSupported]
388 */ 392 */
389 factory $CLASSNAME.tag(String tag) => 393 factory $CLASSNAME.tag(String tag) =>
390 _$(CLASSNAME)FactoryProvider.createElement_tag(tag); 394 _$(CLASSNAME)FactoryProvider.createElement_tag(tag);
391 395
392 /** 396 /**
393 * All attributes on this element. 397 * All attributes on this element.
394 * 398 *
395 * Any modifications to the attribute map will automatically be applied to 399 * Any modifications to the attribute map will automatically be applied to
396 * this element. 400 * this element.
397 * 401 *
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 595 }
592 596
593 /** 597 /**
594 * Parses the specified text as HTML and adds the resulting node after the 598 * Parses the specified text as HTML and adds the resulting node after the
595 * last child of this element. 599 * last child of this element.
596 */ 600 */
597 void appendHtml(String text) { 601 void appendHtml(String text) {
598 this.insertAdjacentHtml('beforeend', text); 602 this.insertAdjacentHtml('beforeend', text);
599 } 603 }
600 604
605 /**
606 * Checks to see if the tag name is supported by the current platform.
607 *
608 * The tag should be a valid HTML tag name.
609 */
610 static bool isTagSupported(String tag) {
611 var e = _ElementFactoryProvider.createElement_tag(tag);
612 return e is Element && !(e is UnknownElement);
613 }
614
601 // Hooks to support custom WebComponents. 615 // Hooks to support custom WebComponents.
602 /** 616 /**
603 * Experimental support for [web components][wc]. This field stores a 617 * Experimental support for [web components][wc]. This field stores a
604 * reference to the component implementation. It was inspired by Mozilla's 618 * reference to the component implementation. It was inspired by Mozilla's
605 * [x-tags][] project. Please note: in the future it may be possible to 619 * [x-tags][] project. Please note: in the future it may be possible to
606 * `extend Element` from your class, in which case this field will be 620 * `extend Element` from your class, in which case this field will be
607 * deprecated and will simply return this [Element] object. 621 * deprecated and will simply return this [Element] object.
608 * 622 *
609 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html 623 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
610 * [x-tags]: http://x-tags.org/ 624 * [x-tags]: http://x-tags.org/
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 'top level elements but 1 expected'); 801 'top level elements but 1 expected');
788 } 802 }
789 element.remove(); 803 element.remove();
790 return element; 804 return element;
791 } 805 }
792 806
793 /** @domName Document.createElement */ 807 /** @domName Document.createElement */
794 $if DART2JS 808 $if DART2JS
795 // Optimization to improve performance until the dart2js compiler inlines this 809 // Optimization to improve performance until the dart2js compiler inlines this
796 // method. 810 // method.
797 static Element createElement_tag(String tag) => 811 static dynamic createElement_tag(String tag) =>
798 JS('Element', 'document.createElement(#)', tag); 812 JS('Element', 'document.createElement(#)', tag);
799 $else 813 $else
800 static Element createElement_tag(String tag) => 814 static Element createElement_tag(String tag) =>
801 document.$dom_createElement(tag); 815 document.$dom_createElement(tag);
802 $endif 816 $endif
803 } 817 }
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/systemnative.py ('k') | sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698