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

Unified 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 8 years 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/templates/html/impl/impl_Element.darttemplate
diff --git a/sdk/lib/html/templates/html/impl/impl_Element.darttemplate b/sdk/lib/html/templates/html/impl/impl_Element.darttemplate
index fc2bcfb2b97b10c5e790c3be901f5586e85d8d67..7708c13667528ed3e1480f81afc590941ffb1791 100644
--- a/sdk/lib/html/templates/html/impl/impl_Element.darttemplate
+++ b/sdk/lib/html/templates/html/impl/impl_Element.darttemplate
@@ -385,6 +385,10 @@ abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
*
* For standard elements it is more preferable to use the type constructors:
* var element = new DivElement();
+ *
+ * See also:
+ *
+ * * [isTagSupported]
*/
factory $CLASSNAME.tag(String tag) =>
_$(CLASSNAME)FactoryProvider.createElement_tag(tag);
@@ -598,6 +602,16 @@ abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
this.insertAdjacentHtml('beforeend', text);
}
+ /**
+ * Checks to see if the tag name is supported by the current platform.
+ *
+ * The tag should be a valid HTML tag name.
+ */
+ static bool isTagSupported(String tag) {
+ var e = _ElementFactoryProvider.createElement_tag(tag);
+ return e is Element && !(e is UnknownElement);
+ }
+
// Hooks to support custom WebComponents.
/**
* Experimental support for [web components][wc]. This field stores a
@@ -794,7 +808,7 @@ class _ElementFactoryProvider {
$if DART2JS
// Optimization to improve performance until the dart2js compiler inlines this
// method.
- static Element createElement_tag(String tag) =>
+ static dynamic createElement_tag(String tag) =>
JS('Element', 'document.createElement(#)', tag);
$else
static Element createElement_tag(String tag) =>
« 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