@@ -4,8 +4,8 @@ import '../_specs.dart';
4
4
import 'dart:js' as js;
5
5
6
6
registerElement (String name, prototype) {
7
- return ( new js.JsObject . fromBrowserObject (document)). callMethod ( 'registerElement' ,
8
- [name, new js.JsObject .jsify ({ " prototype" : prototype } )]);
7
+ js.context[ 'angularTestsRegisterElement' ]. apply (
8
+ [name, new js.JsObject .jsify (prototype)]);
9
9
}
10
10
11
11
@@ -32,22 +32,30 @@ main() {
32
32
(new js.JsObject .fromBrowserObject (_.rootElement))[prop] = value;
33
33
}
34
34
35
+ compileAndUpgrade (String html) {
36
+ _.compile (html);
37
+ var CustomElements = js.context['CustomElements' ];
38
+ if (CustomElements != null ) {
39
+ CustomElements ['upgradeAll' ].apply ([new js.JsObject .fromBrowserObject (_.rootElement)]);
40
+ }
41
+ }
42
+
35
43
beforeEach ((TestBed tb) {
36
44
_ = tb;
37
45
});
38
46
39
- it ('should create custom elements' , () {
47
+ iit ('should create custom elements' , () {
40
48
registerElement ('tests-basic' , {'prop-x' : 6 });
41
49
42
50
// Create a web component
43
- _. compile ('<tests-basic></tests-basic>' );
51
+ compileAndUpgrade ('<tests-basic></tests-basic>' );
44
52
expect (customProp ('prop-x' )).toEqual (6 );
45
53
});
46
54
47
55
48
56
it ('should bind to Custom Element properties' , () {
49
57
registerElement ('tests-bound' , {'prop-y' : 10 });
50
- _. compile ('<tests-bound bind-prop-y=27></tests-bound>' );
58
+ compileAndUpgrade ('<tests-bound bind-prop-y=27></tests-bound>' );
51
59
52
60
// Scope has not been digested yet
53
61
expect (customProp ('prop-y' )).toEqual (10 );
@@ -59,22 +67,22 @@ main() {
59
67
60
68
it ('should bind to a non-existent property' , () {
61
69
registerElement ('tests-empty' , {});
62
- _. compile ('<tests-empty bind-new-prop=27></tests-empty>' );
70
+ compileAndUpgrade ('<tests-empty bind-new-prop=27></tests-empty>' );
63
71
_.rootScope.apply ();
64
72
expect (customProp ('new-prop' )).toEqual (27 );
65
73
});
66
74
67
75
it ('should bind to both directives and properties' , () {
68
76
registerElement ('tests-double' , {});
69
- _. compile ('<tests-double ng-bind bind-ng-bind="\' hello\' "></tests-double>' );
77
+ compileAndUpgrade ('<tests-double ng-bind bind-ng-bind="\' hello\' "></tests-double>' );
70
78
_.rootScope.apply ();
71
79
expect (customProp ('ng-bind' )).toEqual ("hello" );
72
80
expect (_.rootElement).toHaveText ('hello' );
73
81
});
74
82
75
83
it ('should support two-way bindings for components that trigger a change event' , () {
76
84
registerElement ('tests-twoway' , {});
77
- _. compile ('<tests-twoway bind-prop="x"></tests-twoway>' );
85
+ compileAndUpgrade ('<tests-twoway bind-prop="x"></tests-twoway>' );
78
86
79
87
setCustomProp ('prop' , 6 );
80
88
_.rootElement.dispatchEvent (new Event .eventType ('CustomEvent' , 'change' ));
0 commit comments