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

Unified Diff: recipes/web/html/creating_elements.html

Issue 14109034: Recipes for using CSS Selectors with dart:html (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Changes based on Kathy's comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipes/web/html/inserting_elements.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipes/web/html/creating_elements.html
diff --git a/recipes/web/html/creating_elements.html b/recipes/web/html/creating_elements.html
new file mode 100644
index 0000000000000000000000000000000000000000..7fc5e36d7e878407bfa1368921b57119ad4f7185
--- /dev/null
+++ b/recipes/web/html/creating_elements.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+
+<html>
+ <div class='container'></div>
+ <body>
+ <script type="application/dart">
+
+ import 'dart:html';
+
+ void main() {
+
+ // Creating a specific element
+ LIElement item = new LIElement();
+ item.text = 'Mango';
+ assert(item is LIElement);
+ assert(item.innerHtml == 'Mango');
+
+ // Using the Element.html() constructor.
+ assert(new Element.html('<div>I love Strawberries.</div>') is DivElement);
+
+ // Using the Element.tag() constructor
+ var td = new Element.tag('td');
+ td.text = 'guava';
+ assert(td is TableCellElement);
+
+ // Using an invalid tag.
+ assert(new Element.tag('bogusTag') is UnknownElement);
+ assert(Element.isTagSupported('bogusTag') == false);
+
+ // Using another element's outerHtml.
+ var containerDiv = query('div.container');
+ var newDiv = new Element.html(containerDiv.outerHtml);
+ assert(newDiv is DivElement);
+ assert(newDiv.innerHtml == containerDiv.innerHtml);
+ }
+ </script>
+
+
+ <script src="packages/browser/dart.js"></script>
+ </body>
+</html>
« no previous file with comments | « no previous file | recipes/web/html/inserting_elements.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698