| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library XMLElementTest; | |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | |
| 7 import '../../pkg/unittest/lib/html_config.dart'; | |
| 8 import 'dart:html'; | |
| 9 | |
| 10 main() { | |
| 11 useHtmlConfiguration(); | |
| 12 | |
| 13 var isXMLElement = predicate((x) => x is XMLElement, 'is an XMLElement'); | |
| 14 | |
| 15 XMLElement makeElement() => new XMLElement.xml("<xml><foo/><bar/></xml>"); | |
| 16 | |
| 17 makeElementWithParent() { | |
| 18 final parent = new XMLElement.xml( | |
| 19 "<parent><before/><xml><foo/><bar/></xml><after/></parent>"); | |
| 20 return parent.children[1]; | |
| 21 } | |
| 22 | |
| 23 group('constructors', () { | |
| 24 group('.xml', () { | |
| 25 test('with a well-formed document', () { | |
| 26 final el = makeElement(); | |
| 27 expect(el, isXMLElement); | |
| 28 expect(el.children[0].tagName, 'foo'); | |
| 29 expect(el.children[1].tagName, 'bar'); | |
| 30 }); | |
| 31 | |
| 32 test('with too many nodes', () { | |
| 33 expect(() => new XMLElement.xml("<xml></xml>foo"), throwsArgumentError); | |
| 34 }); | |
| 35 | |
| 36 test('with a parse error', () { | |
| 37 expect(() => new XMLElement.xml("<xml></xml>>"), throwsArgumentError); | |
| 38 }); | |
| 39 | |
| 40 test('with a PARSERERROR tag', () { | |
| 41 final el = new XMLElement.xml("<xml><parsererror /></xml>"); | |
| 42 expect('parsererror', el.children[0].tagName, 'parsererror'); | |
| 43 }); | |
| 44 | |
| 45 test('has no parent', () => | |
| 46 expect(new XMLElement.xml('<foo/>').parent), isNull); | |
| 47 }); | |
| 48 | |
| 49 test('.tag', () { | |
| 50 final el = new XMLElement.tag('foo'); | |
| 51 expect(el, isXMLElement); | |
| 52 expect(el.tagName, 'foo'); | |
| 53 }); | |
| 54 }); | |
| 55 | |
| 56 // FilteredElementList is tested more thoroughly in DocumentFragmentTests. | |
| 57 group('children', () { | |
| 58 test('filters out non-element nodes', () { | |
| 59 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); | |
| 60 expect(el.children.mappedBy((e) => e.tagName).toList(), | |
| 61 ["a", "b", "c", "d"]); | |
| 62 }); | |
| 63 | |
| 64 test('overwrites nodes when set', () { | |
| 65 final el = new XMLElement.xml("<xml>1<a/><b/>2<c/>3<d/></xml>"); | |
| 66 el.children = [new XMLElement.tag('x'), new XMLElement.tag('y')]; | |
| 67 expect(el.outerHtml, "<xml><x></x><y></y></xml>"); | |
| 68 }); | |
| 69 }); | |
| 70 | |
| 71 group('classes', () { | |
| 72 XMLElement makeElementWithClasses() => | |
| 73 new XMLElement.xml("<xml class='foo bar baz'></xml>"); | |
| 74 | |
| 75 Set<String> makeClassSet() => makeElementWithClasses().classes; | |
| 76 | |
| 77 test('affects the "class" attribute', () { | |
| 78 final el = makeElementWithClasses(); | |
| 79 el.classes.add('qux'); | |
| 80 expect(el.attributes['class'].split(' '), | |
| 81 unorderedEquals(['foo', 'bar', 'baz', 'qux'])); | |
| 82 }); | |
| 83 | |
| 84 test('is affected by the "class" attribute', () { | |
| 85 final el = makeElementWithClasses(); | |
| 86 el.attributes['class'] = 'foo qux'; | |
| 87 expect(el.classes, unorderedEquals(['foo', 'qux'])); | |
| 88 }); | |
| 89 | |
| 90 test('classes=', () { | |
| 91 final el = makeElementWithClasses(); | |
| 92 el.classes = ['foo', 'qux']; | |
| 93 expect(el.classes, unorderedEquals(['foo', 'qux'])); | |
| 94 expect(el.attributes['class'].split(' '), | |
| 95 unorderedEquals(['foo', 'qux'])); | |
| 96 }); | |
| 97 | |
| 98 test('toString', () { | |
| 99 expect(makeClassSet().toString().split(' '), | |
| 100 unorderedEquals(['foo', 'bar', 'baz'])); | |
| 101 expect(makeElement().classes.toString(), ''); | |
| 102 }); | |
| 103 | |
| 104 test('forEach', () { | |
| 105 final classes = <String>[]; | |
| 106 makeClassSet().forEach(classes.add); | |
| 107 expect(classes, unorderedEquals(['foo', 'bar', 'baz'])); | |
| 108 }); | |
| 109 | |
| 110 test('iterator', () { | |
| 111 final classes = <String>[]; | |
| 112 for (var el in makeClassSet()) { | |
| 113 classes.add(el); | |
| 114 } | |
| 115 expect(classes, unorderedEquals(['foo', 'bar', 'baz'])); | |
| 116 }); | |
| 117 | |
| 118 test('mappedBy', () { | |
| 119 expect(makeClassSet().mappedBy((c) => c.toUpperCase()).toList(), | |
| 120 unorderedEquals(['FOO', 'BAR', 'BAZ'])); | |
| 121 }); | |
| 122 | |
| 123 test('where', () { | |
| 124 expect(makeClassSet().where((c) => c.contains('a')).toSet(), | |
| 125 unorderedEquals(['bar', 'baz'])); | |
| 126 }); | |
| 127 | |
| 128 test('every', () { | |
| 129 expect(makeClassSet().every((c) => c is String), isTrue); | |
| 130 expect(makeClassSet().every((c) => c.contains('a')), isFalse); | |
| 131 }); | |
| 132 | |
| 133 test('any', () { | |
| 134 expect(makeClassSet().any((c) => c.contains('a')), isTrue); | |
| 135 expect(makeClassSet().any((c) => c is num), isFalse); | |
| 136 }); | |
| 137 | |
| 138 test('isEmpty', () { | |
| 139 expect(makeClassSet().isEmpty, isFalse); | |
| 140 expect(makeElement().classes.isEmpty, isTrue); | |
| 141 }); | |
| 142 | |
| 143 test('length', () { | |
| 144 expect(makeClassSet().length, 3); | |
| 145 expect(makeElement().classes.length, 0); | |
| 146 }); | |
| 147 | |
| 148 test('contains', () { | |
| 149 expect(makeClassSet().contains('foo'), isTrue); | |
| 150 expect(makeClassSet().contains('qux'), isFalse); | |
| 151 }); | |
| 152 | |
| 153 test('add', () { | |
| 154 final classes = makeClassSet(); | |
| 155 classes.add('qux'); | |
| 156 expect(classes, unorderedEquals(['foo', 'bar', 'baz', 'qux'])); | |
| 157 | |
| 158 classes.add('qux'); | |
| 159 final list = new List.from(classes); | |
| 160 list.sort((a, b) => a.compareTo(b)); | |
| 161 expect(list, ['bar', 'baz', 'foo', 'qux'], | |
| 162 reason: "The class set shouldn't have duplicate elements."); | |
| 163 }); | |
| 164 | |
| 165 test('remove', () { | |
| 166 final classes = makeClassSet(); | |
| 167 classes.remove('bar'); | |
| 168 expect(classes, unorderedEquals(['foo', 'baz'])); | |
| 169 classes.remove('qux'); | |
| 170 expect(classes, unorderedEquals(['foo', 'baz'])); | |
| 171 }); | |
| 172 | |
| 173 test('addAll', () { | |
| 174 final classes = makeClassSet(); | |
| 175 classes.addAll(['bar', 'qux', 'bip']); | |
| 176 expect(classes, unorderedEquals(['foo', 'bar', 'baz', 'qux', 'bip'])); | |
| 177 }); | |
| 178 | |
| 179 test('removeAll', () { | |
| 180 final classes = makeClassSet(); | |
| 181 classes.removeAll(['bar', 'baz', 'qux']); | |
| 182 expect(classes, ['foo']); | |
| 183 }); | |
| 184 | |
| 185 test('isSubsetOf', () { | |
| 186 final classes = makeClassSet(); | |
| 187 expect(classes.isSubsetOf(['foo', 'bar', 'baz']), isTrue); | |
| 188 expect(classes.isSubsetOf(['foo', 'bar', 'baz', 'qux']), isTrue); | |
| 189 expect(classes.isSubsetOf(['foo', 'bar', 'qux']), isFalse); | |
| 190 }); | |
| 191 | |
| 192 test('containsAll', () { | |
| 193 final classes = makeClassSet(); | |
| 194 expect(classes.containsAll(['foo', 'baz']), isTrue); | |
| 195 expect(classes.containsAll(['foo', 'qux']), isFalse); | |
| 196 }); | |
| 197 | |
| 198 test('intersection', () { | |
| 199 final classes = makeClassSet(); | |
| 200 expect(classes.intersection(['foo', 'qux', 'baz']), | |
| 201 unorderedEquals(['foo', 'baz'])); | |
| 202 }); | |
| 203 | |
| 204 test('clear', () { | |
| 205 final classes = makeClassSet(); | |
| 206 classes.clear(); | |
| 207 expect(classes, []); | |
| 208 }); | |
| 209 }); | |
| 210 | |
| 211 test("no-op methods don't throw errors", () { | |
| 212 final el = makeElement(); | |
| 213 el.on.click.add((e) => null); | |
| 214 el.blur(); | |
| 215 el.focus(); | |
| 216 el.scrollByLines(2); | |
| 217 el.scrollByPages(2); | |
| 218 el.scrollIntoView(); | |
| 219 }); | |
| 220 | |
| 221 group('properties that map to attributes', () { | |
| 222 group('contentEditable', () { | |
| 223 test('get', () { | |
| 224 final el = makeElement(); | |
| 225 expect(el.contentEditable, 'inherit'); | |
| 226 el.attributes['contentEditable'] = 'foo'; | |
| 227 expect(el.contentEditable, 'foo'); | |
| 228 }); | |
| 229 | |
| 230 test('set', () { | |
| 231 final el = makeElement(); | |
| 232 el.contentEditable = 'foo'; | |
| 233 expect(el.attributes['contentEditable'], 'foo'); | |
| 234 }); | |
| 235 | |
| 236 test('isContentEditable', () { | |
| 237 final el = makeElement(); | |
| 238 expect(el.isContentEditable, isFalse); | |
| 239 el.contentEditable = 'true'; | |
| 240 expect(el.isContentEditable, isFalse); | |
| 241 }); | |
| 242 }); | |
| 243 | |
| 244 group('draggable', () { | |
| 245 test('get', () { | |
| 246 final el = makeElement(); | |
| 247 expect(el.draggable, isFalse); | |
| 248 el.attributes['draggable'] = 'true'; | |
| 249 expect(el.draggable, isTrue); | |
| 250 el.attributes['draggable'] = 'foo'; | |
| 251 expect(el.draggable, isFalse); | |
| 252 }); | |
| 253 | |
| 254 test('set', () { | |
| 255 final el = makeElement(); | |
| 256 el.draggable = true; | |
| 257 expect(el.attributes['draggable'], 'true'); | |
| 258 el.draggable = false; | |
| 259 expect(el.attributes['draggable'], 'false'); | |
| 260 }); | |
| 261 }); | |
| 262 | |
| 263 group('spellcheck', () { | |
| 264 test('get', () { | |
| 265 final el = makeElement(); | |
| 266 expect(el.spellcheck, isFalse); | |
| 267 el.attributes['spellcheck'] = 'true'; | |
| 268 expect(el.spellcheck, isTrue); | |
| 269 el.attributes['spellcheck'] = 'foo'; | |
| 270 expect(el.spellcheck, isFalse); | |
| 271 }); | |
| 272 | |
| 273 test('set', () { | |
| 274 final el = makeElement(); | |
| 275 el.spellcheck = true; | |
| 276 expect(el.attributes['spellcheck'], 'true'); | |
| 277 el.spellcheck = false; | |
| 278 expect(el.attributes['spellcheck'], 'false'); | |
| 279 }); | |
| 280 }); | |
| 281 | |
| 282 group('hidden', () { | |
| 283 test('get', () { | |
| 284 final el = makeElement(); | |
| 285 expect(el.hidden, isFalse); | |
| 286 el.attributes['hidden'] = ''; | |
| 287 expect(el.hidden, isTrue); | |
| 288 }); | |
| 289 | |
| 290 test('set', () { | |
| 291 final el = makeElement(); | |
| 292 el.hidden = true; | |
| 293 expect(el.attributes['hidden'], ''); | |
| 294 el.hidden = false; | |
| 295 expect(el.attributes.containsKey('hidden'), isFalse); | |
| 296 }); | |
| 297 }); | |
| 298 | |
| 299 group('tabIndex', () { | |
| 300 test('get', () { | |
| 301 final el = makeElement(); | |
| 302 expect(el.tabIndex, 0); | |
| 303 el.attributes['tabIndex'] = '2'; | |
| 304 expect(el.tabIndex, 2); | |
| 305 el.attributes['tabIndex'] = 'foo'; | |
| 306 expect(el.tabIndex, 0); | |
| 307 }); | |
| 308 | |
| 309 test('set', () { | |
| 310 final el = makeElement(); | |
| 311 el.tabIndex = 15; | |
| 312 expect(el.attributes['tabIndex'], '15'); | |
| 313 }); | |
| 314 }); | |
| 315 | |
| 316 group('id', () { | |
| 317 test('get', () { | |
| 318 final el = makeElement(); | |
| 319 expect(el.id, ''); | |
| 320 el.attributes['id'] = 'foo'; | |
| 321 expect(el.id, 'foo'); | |
| 322 }); | |
| 323 | |
| 324 test('set', () { | |
| 325 final el = makeElement(); | |
| 326 el.id = 'foo'; | |
| 327 expect(el.attributes['id'], 'foo'); | |
| 328 }); | |
| 329 }); | |
| 330 | |
| 331 group('title', () { | |
| 332 test('get', () { | |
| 333 final el = makeElement(); | |
| 334 expect(el.title, ''); | |
| 335 el.attributes['title'] = 'foo'; | |
| 336 expect(el.title, 'foo'); | |
| 337 }); | |
| 338 | |
| 339 test('set', () { | |
| 340 final el = makeElement(); | |
| 341 el.title = 'foo'; | |
| 342 expect(el.attributes['title'], 'foo'); | |
| 343 }); | |
| 344 }); | |
| 345 | |
| 346 group('webkitdropzone', () { | |
| 347 test('get', () { | |
| 348 final el = makeElement(); | |
| 349 expect(el.webkitdropzone, ''); | |
| 350 el.attributes['webkitdropzone'] = 'foo'; | |
| 351 expect(el.webkitdropzone, 'foo'); | |
| 352 }); | |
| 353 | |
| 354 test('set', () { | |
| 355 final el = makeElement(); | |
| 356 el.webkitdropzone = 'foo'; | |
| 357 expect(el.attributes['webkitdropzone'], 'foo'); | |
| 358 }); | |
| 359 }); | |
| 360 | |
| 361 group('lang', () { | |
| 362 test('get', () { | |
| 363 final el = makeElement(); | |
| 364 expect(el.lang, ''); | |
| 365 el.attributes['lang'] = 'foo'; | |
| 366 expect(el.lang, 'foo'); | |
| 367 }); | |
| 368 | |
| 369 test('set', () { | |
| 370 final el = makeElement(); | |
| 371 el.lang = 'foo'; | |
| 372 expect(el.attributes['lang'], 'foo'); | |
| 373 }); | |
| 374 }); | |
| 375 | |
| 376 group('dir', () { | |
| 377 test('get', () { | |
| 378 final el = makeElement(); | |
| 379 expect(el.dir, ''); | |
| 380 el.attributes['dir'] = 'foo'; | |
| 381 expect(el.dir, 'foo'); | |
| 382 }); | |
| 383 | |
| 384 test('set', () { | |
| 385 final el = makeElement(); | |
| 386 el.dir = 'foo'; | |
| 387 expect(el.attributes['dir'], 'foo'); | |
| 388 }); | |
| 389 }); | |
| 390 }); | |
| 391 | |
| 392 test('set innerHtml', () { | |
| 393 final el = makeElement(); | |
| 394 el.innerHtml = "<foo>Bar<baz/></foo>"; | |
| 395 expect(el.nodes.length, 1); | |
| 396 final node = el.nodes[0]; | |
| 397 expect(node, isXMLElement); | |
| 398 expect(node.tagName, 'foo'); | |
| 399 expect(node.nodes[0].text, 'Bar'); | |
| 400 expect(node.nodes[1].tagName, 'baz'); | |
| 401 }); | |
| 402 | |
| 403 test('get innerHtml/outerHtml', () { | |
| 404 final el = makeElement(); | |
| 405 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 406 el.nodes.clear(); | |
| 407 el.nodes.addAll([new Text("foo"), new XMLElement.xml("<a>bar</a>")]); | |
| 408 expect(el.innerHtml, "foo<a>bar</a>"); | |
| 409 expect(el.outerHtml, "<xml>foo<a>bar</a></xml>"); | |
| 410 }); | |
| 411 | |
| 412 test('query', () { | |
| 413 final el = makeElement(); | |
| 414 expect(el.query('foo').tagName, 'foo'); | |
| 415 expect(el.query('baz'), isNull); | |
| 416 }); | |
| 417 | |
| 418 test('queryAll', () { | |
| 419 final el = new XMLElement.xml( | |
| 420 "<xml><foo id='f1' /><bar><foo id='f2' /></bar></xml>"); | |
| 421 expect(el.queryAll('foo').mappedBy((e) => e.id).toList(), ['f1', 'f2']); | |
| 422 expect(el.queryAll('baz'), []); | |
| 423 }); | |
| 424 | |
| 425 // TODO(nweiz): re-enable this when matchesSelector works cross-browser. | |
| 426 // | |
| 427 // test('matchesSelector', () { | |
| 428 // final el = makeElement(); | |
| 429 // expect(el.matchesSelector('*'), isTrue); | |
| 430 // expect(el.matchesSelector('xml'), isTrue); | |
| 431 // expect(el.matchesSelector('html'), isFalse); | |
| 432 // }); | |
| 433 | |
| 434 group('insertAdjacentElement', () { | |
| 435 test('beforeBegin with no parent does nothing', () { | |
| 436 final el = makeElement(); | |
| 437 expect(el.insertAdjacentElement("beforeBegin", new XMLElement.tag("b")), | |
| 438 isNull); | |
| 439 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 440 }); | |
| 441 | |
| 442 test('afterEnd with no parent does nothing', () { | |
| 443 final el = makeElement(); | |
| 444 expect( | |
| 445 el.insertAdjacentElement("afterEnd", new XMLElement.tag("b")), isNull); | |
| 446 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 447 }); | |
| 448 | |
| 449 test('beforeBegin with parent inserts the element', () { | |
| 450 final el = makeElementWithParent(); | |
| 451 final newEl = new XMLElement.tag("b"); | |
| 452 expect(el.insertAdjacentElement("beforeBegin", newEl), newEl); | |
| 453 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 454 expect(el.parent.innerHtml, | |
| 455 "<before></before><b></b><xml><foo></foo><bar></bar>" | |
| 456 "</xml><after></after>"); | |
| 457 }); | |
| 458 | |
| 459 test('afterEnd with parent inserts the element', () { | |
| 460 final el = makeElementWithParent(); | |
| 461 final newEl = new XMLElement.tag("b"); | |
| 462 expect(el.insertAdjacentElement("afterEnd", newEl), newEl); | |
| 463 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 464 expect(el.parent.innerHtml, | |
| 465 "<before></before><xml><foo></foo><bar></bar></xml><b>" | |
| 466 "</b><after></after>"); | |
| 467 }); | |
| 468 | |
| 469 test('afterBegin inserts the element', () { | |
| 470 final el = makeElement(); | |
| 471 final newEl = new XMLElement.tag("b"); | |
| 472 expect(el.insertAdjacentElement("afterBegin", newEl), newEl); | |
| 473 expect(el.innerHtml, "<b></b><foo></foo><bar></bar>"); | |
| 474 }); | |
| 475 | |
| 476 test('beforeEnd inserts the element', () { | |
| 477 final el = makeElement(); | |
| 478 final newEl = new XMLElement.tag("b"); | |
| 479 expect(el.insertAdjacentElement("beforeEnd", newEl), newEl); | |
| 480 expect(el.innerHtml, "<foo></foo><bar></bar><b></b>"); | |
| 481 }); | |
| 482 }); | |
| 483 | |
| 484 group('insertAdjacentText', () { | |
| 485 test('beforeBegin with no parent does nothing', () { | |
| 486 final el = makeElement(); | |
| 487 el.insertAdjacentText("beforeBegin", "foo"); | |
| 488 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 489 }); | |
| 490 | |
| 491 test('afterEnd with no parent does nothing', () { | |
| 492 final el = makeElement(); | |
| 493 el.insertAdjacentText("afterEnd", "foo"); | |
| 494 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 495 }); | |
| 496 | |
| 497 test('beforeBegin with parent inserts the text', () { | |
| 498 final el = makeElementWithParent(); | |
| 499 el.insertAdjacentText("beforeBegin", "foo"); | |
| 500 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 501 expect(el.parent.innerHtml, | |
| 502 "<before></before>foo<xml><foo></foo><bar></bar></xml>" | |
| 503 "<after></after>"); | |
| 504 }); | |
| 505 | |
| 506 test('afterEnd with parent inserts the text', () { | |
| 507 final el = makeElementWithParent(); | |
| 508 el.insertAdjacentText("afterEnd", "foo"); | |
| 509 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 510 expect(el.parent.innerHtml, | |
| 511 "<before></before><xml><foo></foo><bar></bar></xml>foo" | |
| 512 "<after></after>"); | |
| 513 }); | |
| 514 | |
| 515 test('afterBegin inserts the text', () { | |
| 516 final el = makeElement(); | |
| 517 el.insertAdjacentText("afterBegin", "foo"); | |
| 518 expect(el.innerHtml, "foo<foo></foo><bar></bar>"); | |
| 519 }); | |
| 520 | |
| 521 test('beforeEnd inserts the text', () { | |
| 522 final el = makeElement(); | |
| 523 el.insertAdjacentText("beforeEnd", "foo"); | |
| 524 expect(el.innerHtml, "<foo></foo><bar></bar>foo"); | |
| 525 }); | |
| 526 }); | |
| 527 | |
| 528 group('insertAdjacentHtml', () { | |
| 529 test('beforeBegin with no parent does nothing', () { | |
| 530 final el = makeElement(); | |
| 531 el.insertAdjacentHtml("beforeBegin", "foo<b/>"); | |
| 532 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 533 }); | |
| 534 | |
| 535 test('afterEnd with no parent does nothing', () { | |
| 536 final el = makeElement(); | |
| 537 el.insertAdjacentHtml("afterEnd", "<b/>foo"); | |
| 538 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 539 }); | |
| 540 | |
| 541 test('beforeBegin with parent inserts the HTML', () { | |
| 542 final el = makeElementWithParent(); | |
| 543 el.insertAdjacentHtml("beforeBegin", "foo<b/>"); | |
| 544 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 545 expect(el.parent.innerHtml, | |
| 546 "<before></before>foo<b></b><xml><foo></foo><bar></bar>" | |
| 547 "</xml><after></after>"); | |
| 548 }); | |
| 549 | |
| 550 test('afterEnd with parent inserts the HTML', () { | |
| 551 final el = makeElementWithParent(); | |
| 552 el.insertAdjacentHtml("afterEnd", "foo<b/>"); | |
| 553 expect(el.innerHtml, "<foo></foo><bar></bar>"); | |
| 554 expect(el.parent.innerHtml, | |
| 555 "<before></before><xml><foo></foo><bar></bar></xml>foo" | |
| 556 "<b></b><after></after>"); | |
| 557 }); | |
| 558 | |
| 559 test('afterBegin inserts the HTML', () { | |
| 560 final el = makeElement(); | |
| 561 el.insertAdjacentHtml("afterBegin", "foo<b/>"); | |
| 562 expect(el.innerHtml, "foo<b></b><foo></foo><bar></bar>"); | |
| 563 }); | |
| 564 | |
| 565 test('beforeEnd inserts the HTML', () { | |
| 566 final el = makeElement(); | |
| 567 el.insertAdjacentHtml("beforeEnd", "<b/>foo"); | |
| 568 expect(el.innerHtml, "<foo></foo><bar></bar><b></b>foo"); | |
| 569 }); | |
| 570 }); | |
| 571 | |
| 572 test('default rect values', () { | |
| 573 makeElement().rect.then( | |
| 574 expectAsync1(ElementRect rect) { | |
| 575 expectEmptyRect(rect.client); | |
| 576 expectEmptyRect(rect.offset); | |
| 577 expectEmptyRect(rect.scroll); | |
| 578 expectEmptyRect(rect.bounding); | |
| 579 expect(rect.clientRects.isEmpty, isTrue); | |
| 580 })); | |
| 581 }); | |
| 582 } | |
| OLD | NEW |