| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 library ElementTest; | 5 library ElementTest; |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 7 import '../../pkg/unittest/lib/html_individual_config.dart'; | 7 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'dart:svg' as svg; | 10 import 'dart:svg' as svg; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 'is a TableSectionElement')); | 178 'is a TableSectionElement')); |
| 179 expect(node.tagName, 'TFOOT'); | 179 expect(node.tagName, 'TFOOT'); |
| 180 expect(node.parent, isNull); | 180 expect(node.parent, isNull); |
| 181 expect(node.rows.length, 1); | 181 expect(node.rows.length, 1); |
| 182 expect(node.rows[0].cells.length, 2); | 182 expect(node.rows[0].cells.length, 2); |
| 183 expect(node.innerHtml, innerHtml); | 183 expect(node.innerHtml, innerHtml); |
| 184 }); | 184 }); |
| 185 | 185 |
| 186 test('.html tr', () { | 186 test('.html tr', () { |
| 187 var table = new TableElement(); | 187 var table = new TableElement(); |
| 188 document.body.append(table); |
| 188 var tBody = table.createTBody(); | 189 var tBody = table.createTBody(); |
| 189 var node = tBody.createFragment('<tr><td>foo<td>bar').nodes.single; | 190 var node = tBody.createFragment('<tr><td>foo<td>bar').nodes.single; |
| 190 expect(node, predicate((x) => x is TableRowElement, | 191 expect(node, predicate((x) => x is TableRowElement, |
| 191 'is a TableRowElement')); | 192 'is a TableRowElement')); |
| 192 expect(node.tagName, 'TR'); | 193 expect(node.tagName, 'TR'); |
| 193 expect(node.parent, isNull); | 194 expect(node.parent, isNull); |
| 194 expect(node.cells.map((c) => c.innerHtml), ['foo', 'bar']); | 195 expect(node.cells.map((c) => c.innerHtml), ['foo', 'bar']); |
| 195 }); | 196 }); |
| 196 | 197 |
| 197 test('.html td', () { | 198 test('.html td', () { |
| 198 var table = new TableElement(); | 199 var table = new TableElement(); |
| 200 document.body.append(table); |
| 199 var tBody = table.createTBody(); | 201 var tBody = table.createTBody(); |
| 200 var tRow = tBody.addRow(); | 202 var tRow = tBody.addRow(); |
| 201 var node = tRow.createFragment('<td>foobar').nodes.single; | 203 var node = tRow.createFragment('<td>foobar').nodes.single; |
| 202 expect(node, predicate((x) => x is TableCellElement, | 204 expect(node, predicate((x) => x is TableCellElement, |
| 203 'is a TableCellElement')); | 205 'is a TableCellElement')); |
| 204 expect(node.tagName, 'TD'); | 206 expect(node.tagName, 'TD'); |
| 205 expect(node.parent, isNull); | 207 expect(node.parent, isNull); |
| 206 expect(node.innerHtml, 'foobar'); | 208 expect(node.innerHtml, 'foobar'); |
| 207 }); | 209 }); |
| 208 | 210 |
| 209 test('.html th', () { | 211 test('.html th', () { |
| 210 var table = new TableElement(); | 212 var table = new TableElement(); |
| 213 document.body.append(table); |
| 211 var tBody = table.createTBody(); | 214 var tBody = table.createTBody(); |
| 212 var tRow = tBody.addRow(); | 215 var tRow = tBody.addRow(); |
| 213 var node = tRow.createFragment('<th>foobar').nodes.single; | 216 var node = tRow.createFragment('<th>foobar').nodes.single; |
| 214 expect(node, predicate((x) => x is TableCellElement, | 217 expect(node, predicate((x) => x is TableCellElement, |
| 215 'is a TableCellElement')); | 218 'is a TableCellElement')); |
| 216 expect(node.tagName, 'TH'); | 219 expect(node.tagName, 'TH'); |
| 217 expect(node.parent, isNull); | 220 expect(node.parent, isNull); |
| 218 expect(node.innerHtml, 'foobar'); | 221 expect(node.innerHtml, 'foobar'); |
| 219 }); | 222 }); |
| 220 }); | 223 }); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 589 |
| 587 testUnsupported('insertAll', () { | 590 testUnsupported('insertAll', () { |
| 588 var l = makeElementWithChildren().children; | 591 var l = makeElementWithChildren().children; |
| 589 l.insertAll(0, []); | 592 l.insertAll(0, []); |
| 590 }); | 593 }); |
| 591 }); | 594 }); |
| 592 | 595 |
| 593 group('matches', () { | 596 group('matches', () { |
| 594 test('matches', () { | 597 test('matches', () { |
| 595 var element = new DivElement(); | 598 var element = new DivElement(); |
| 599 document.body.append(element); |
| 596 element.classes.add('test'); | 600 element.classes.add('test'); |
| 597 | 601 |
| 598 expect(element.matches('div'), true); | 602 expect(element.matches('div'), true); |
| 599 expect(element.matches('span'), false); | 603 expect(element.matches('span'), false); |
| 600 expect(element.matches('.test'), true); | 604 expect(element.matches('.test'), true); |
| 601 }); | 605 }); |
| 602 }); | 606 }); |
| 603 | 607 |
| 604 group('queryAll', () { | 608 group('queryAll', () { |
| 605 List<Element> getQueryAll() { | 609 List<Element> getQueryAll() { |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 | 895 |
| 892 test('sublist', () { | 896 test('sublist', () { |
| 893 var range = makeElementList().sublist(1, 3); | 897 var range = makeElementList().sublist(1, 3); |
| 894 expect(range.length, 2); | 898 expect(range.length, 2); |
| 895 expect(range[0], isBRElement); | 899 expect(range[0], isBRElement); |
| 896 expect(range[1], isBRElement); | 900 expect(range[1], isBRElement); |
| 897 }); | 901 }); |
| 898 | 902 |
| 899 }); | 903 }); |
| 900 } | 904 } |
| OLD | NEW |