| OLD | NEW |
| 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 library ElementAddTest; | 5 library ElementAddTest; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 7 import 'package:unittest/html_config.dart'; |
| 8 import 'util.dart'; | 8 import 'util.dart'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 expect(el.children[0], equals(span)); | 55 expect(el.children[0], equals(span)); |
| 56 expect(el.children[1], isDivElement); | 56 expect(el.children[1], isDivElement); |
| 57 }); | 57 }); |
| 58 | 58 |
| 59 test('documentFragment', () { | 59 test('documentFragment', () { |
| 60 var fragment = new DocumentFragment(); | 60 var fragment = new DocumentFragment(); |
| 61 fragment.appendHtml('<span>something</span>'); | 61 fragment.appendHtml('<span>something</span>'); |
| 62 expect(fragment.children.length, equals(1)); | 62 expect(fragment.children.length, equals(1)); |
| 63 expect(fragment.children[0], isSpanElement); | 63 expect(fragment.children[0], isSpanElement); |
| 64 }); | 64 }); |
| 65 | |
| 66 test('html interpreted in correct context', () { | |
| 67 var el = new TableElement(); | |
| 68 el.appendHtml('<tr><td>foo</td></tr>'); | |
| 69 expect(el.children.length, 1); | |
| 70 var section = el.children.first; | |
| 71 expect(section is TableSectionElement, isTrue); | |
| 72 var row = section.children.first; | |
| 73 expect(row is TableRowElement, isTrue); | |
| 74 var item = row.children.first; | |
| 75 expect(item is TableCellElement, isTrue); | |
| 76 expect(item.innerHtml, 'foo'); | |
| 77 }); | |
| 78 }); | 65 }); |
| 79 | 66 |
| 80 group('appendText', () { | 67 group('appendText', () { |
| 81 test('htmlelement', () { | 68 test('htmlelement', () { |
| 82 var el = new DivElement(); | 69 var el = new DivElement(); |
| 83 el.appendText('foo'); | 70 el.appendText('foo'); |
| 84 // No children were created. | 71 // No children were created. |
| 85 expect(el.children.length, equals(0)); | 72 expect(el.children.length, equals(0)); |
| 86 // One text node was added. | 73 // One text node was added. |
| 87 expect(el.nodes.length, equals(1)); | 74 expect(el.nodes.length, equals(1)); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 var child = new DivElement(); | 232 var child = new DivElement(); |
| 246 parent.children.add(child); | 233 parent.children.add(child); |
| 247 | 234 |
| 248 parent.insertAdjacentText('beforeend', 'test'); | 235 parent.insertAdjacentText('beforeend', 'test'); |
| 249 | 236 |
| 250 expect(parent.nodes.length, 2); | 237 expect(parent.nodes.length, 2); |
| 251 expect(parent.nodes[1], isText); | 238 expect(parent.nodes[1], isText); |
| 252 }); | 239 }); |
| 253 }); | 240 }); |
| 254 } | 241 } |
| OLD | NEW |