This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,25 @@ class ViewPort {
82
82
/// The associated scope is destroyed immediately.
83
83
View remove (View view) {
84
84
view.scope.destroy ();
85
+
86
+ // The view removal is sync, and the corresponding DOM operation is async.
85
87
views.remove (view);
86
88
scope.rootScope.domWrite (() {
89
+
90
+ /**
91
+ * We have to call `views.remove` one more time to handle the case when a view gets
92
+ * inserted and removed in the VM turn.
93
+ *
94
+ * viewPort.insert(a);
95
+ * viewPort.remove(a);
96
+ *
97
+ * Another option of making the view insertion synchronous does not work because of:
98
+ * https://github.com/angular/angular.dart/issues/1630
99
+ *
100
+ * Remove this once Issue 1630 is fixed.
101
+ */
102
+ views.remove (view);
103
+
87
104
_animate.remove (view.nodes);
88
105
_notifyLightDom ();
89
106
});
Original file line number Diff line number Diff line change @@ -131,21 +131,29 @@ main() {
131
131
132
132
133
133
describe ('remove' , () {
134
- beforeEach ( (RootScope scope) {
134
+ it ( "should remove newly added view" , (RootScope scope) {
135
135
viewPort.insert (a);
136
- viewPort.insert (b, insertAfter : a);
136
+ viewPort.remove ( a);
137
137
scope.flush ();
138
138
139
- expect (rootElement.text ).toEqual ('AaBb' );
139
+ expect (viewPort.views ).toEqual ([] );
140
140
});
141
141
142
142
it ('should remove the last view' , (RootScope scope) {
143
+ viewPort.insert (a);
144
+ viewPort.insert (b, insertAfter: a);
145
+ scope.flush ();
146
+
143
147
viewPort.remove (b);
144
148
scope.flush ();
145
149
expect (rootElement).toHaveHtml ('<!-- anchor --><span>A</span>a' );
146
150
});
147
151
148
152
it ('should remove child views from parent pseudo black' , (RootScope scope) {
153
+ viewPort.insert (a);
154
+ viewPort.insert (b, insertAfter: a);
155
+ scope.flush ();
156
+
149
157
viewPort.remove (a);
150
158
scope.flush ();
151
159
expect (rootElement).toHaveHtml ('<!-- anchor --><span>B</span>b' );
You can’t perform that action at this time.
0 commit comments