| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 document_register_basic_test; | 5 library document_register_basic_test; |
| 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 'dart:html'; | 8 import 'dart:html'; |
| 9 import '../utils.dart'; | |
| 10 | 9 |
| 11 class Foo extends HtmlElement { | 10 class Foo extends HtmlElement { |
| 12 static final tag = 'x-foo'; | 11 static final tag = 'x-foo'; |
| 13 factory Foo() => new Element.tag(tag); | 12 factory Foo() => new Element.tag(tag); |
| 14 | 13 |
| 15 get thisIsACustomClass => true; | 14 get thisIsACustomClass => true; |
| 16 } | 15 } |
| 17 | 16 |
| 18 class Bar extends HtmlElement { | 17 class Bar extends HtmlElement { |
| 19 static final tag = 'x-bar'; | 18 static final tag = 'x-bar'; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 expect(createdFoo.text, "Hello"); | 76 expect(createdFoo.text, "Hello"); |
| 78 | 77 |
| 79 // Native method | 78 // Native method |
| 80 var childDiv = new DivElement(); | 79 var childDiv = new DivElement(); |
| 81 createdFoo.append(childDiv); | 80 createdFoo.append(childDiv); |
| 82 expect(createdFoo.lastChild, childDiv); | 81 expect(createdFoo.lastChild, childDiv); |
| 83 | 82 |
| 84 // Parser initiated instantiation | 83 // Parser initiated instantiation |
| 85 var container = new DivElement()..id = "container"; | 84 var container = new DivElement()..id = "container"; |
| 86 document.body.append(container); | 85 document.body.append(container); |
| 87 container.setInnerHtml("<x-foo></x-foo>", | 86 container.innerHtml = "<x-foo></x-foo>"; |
| 88 treeSanitizer: new NullTreeSanitizer()); | |
| 89 var parsedFoo = container.firstChild; | 87 var parsedFoo = container.firstChild; |
| 90 | 88 |
| 91 expect(parsedFoo is Foo, isTrue); | 89 expect(parsedFoo is Foo, isTrue); |
| 92 expect(parsedFoo.tagName, "X-FOO"); | 90 expect(parsedFoo.tagName, "X-FOO"); |
| 93 | 91 |
| 94 // Ensuring the wrapper is retained | 92 // Ensuring the wrapper is retained |
| 95 var someProperty = new Expando(); | 93 var someProperty = new Expando(); |
| 96 someProperty[parsedFoo] = "hello"; | 94 someProperty[parsedFoo] = "hello"; |
| 97 expect(container.firstChild, parsedFoo); | 95 expect(container.firstChild, parsedFoo); |
| 98 expect(someProperty[container.firstChild], someProperty[parsedFoo]); | 96 expect(someProperty[container.firstChild], someProperty[parsedFoo]); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 112 expect(createdBaz.thisIsAlsoACustomClass, isTrue); | 110 expect(createdBaz.thisIsAlsoACustomClass, isTrue); |
| 113 | 111 |
| 114 // With irregular cases | 112 // With irregular cases |
| 115 var createdUpperBar = new Element.tag("X-BAR"); | 113 var createdUpperBar = new Element.tag("X-BAR"); |
| 116 var createdMixedBar = new Element.tag("X-Bar"); | 114 var createdMixedBar = new Element.tag("X-Bar"); |
| 117 expect(createdUpperBar is Bar, isTrue); | 115 expect(createdUpperBar is Bar, isTrue); |
| 118 expect(createdUpperBar.tagName, "X-BAR"); | 116 expect(createdUpperBar.tagName, "X-BAR"); |
| 119 expect(createdMixedBar is Bar, isTrue); | 117 expect(createdMixedBar is Bar, isTrue); |
| 120 expect(createdMixedBar.tagName, "X-BAR"); | 118 expect(createdMixedBar.tagName, "X-BAR"); |
| 121 | 119 |
| 122 container.setInnerHtml("<X-BAR></X-BAR><X-Bar></X-Bar>", | 120 container.innerHtml = "<X-BAR></X-BAR><X-Bar></X-Bar>"; |
| 123 treeSanitizer: new NullTreeSanitizer()); | |
| 124 expect(container.firstChild is Bar, isTrue); | 121 expect(container.firstChild is Bar, isTrue); |
| 125 expect(container.firstChild.tagName, "X-BAR"); | 122 expect(container.firstChild.tagName, "X-BAR"); |
| 126 expect(container.lastChild is Bar, isTrue); | 123 expect(container.lastChild is Bar, isTrue); |
| 127 expect(container.lastChild.tagName, "X-BAR"); | 124 expect(container.lastChild.tagName, "X-BAR"); |
| 128 | 125 |
| 129 // Constructors shouldn't interfere with each other | 126 // Constructors shouldn't interfere with each other |
| 130 expect((new Foo()).tagName, "X-FOO"); | 127 expect((new Foo()).tagName, "X-FOO"); |
| 131 expect((new Bar()).tagName, "X-BAR"); | 128 expect((new Bar()).tagName, "X-BAR"); |
| 132 expect((new Baz()).tagName, "X-BAZ"); | 129 expect((new Baz()).tagName, "X-BAZ"); |
| 133 }); | 130 }); |
| 134 } | 131 } |
| OLD | NEW |