Skip to content

Commit c729560

Browse files
vsavkindsalsbury
authored andcommitted
refactor(compiler): remove WalkingCompiler and WalkingViewFactory
1 parent d3d705d commit c729560

File tree

5 files changed

+9
-218
lines changed

5 files changed

+9
-218
lines changed

lib/core_dom/module_internal.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ part 'transcluding_component_factory.dart';
5050
part 'tree_sanitizer.dart';
5151
part 'view.dart';
5252
part 'view_factory.dart';
53-
part 'walking_compiler.dart';
5453
part 'web_platform.dart';
5554

5655
class CoreDomModule extends Module {

lib/core_dom/view_factory.dart

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -26,100 +26,6 @@ abstract class ViewFactory implements Function {
2626
View call(Scope scope, DirectiveInjector directiveInjector, [List<dom.Node> elements]);
2727
}
2828

29-
/**
30-
* [WalkingViewFactory] is used to create new [View]s. WalkingViewFactory is
31-
* created by the [Compiler] as a result of compiling a template.
32-
*/
33-
class WalkingViewFactory implements ViewFactory {
34-
final List<ElementBinderTreeRef> elementBinders;
35-
final List<dom.Node> templateElements;
36-
final Profiler _perf;
37-
final Expando _expando;
38-
39-
WalkingViewFactory(this.templateElements, this.elementBinders, this._perf,
40-
this._expando) {
41-
assert(elementBinders.every((ElementBinderTreeRef eb) =>
42-
eb is ElementBinderTreeRef));
43-
}
44-
45-
BoundViewFactory bind(DirectiveInjector directiveInjector) =>
46-
new BoundViewFactory(this, directiveInjector);
47-
48-
View call(Scope scope, DirectiveInjector directiveInjector, [List<dom.Node> nodes]) {
49-
assert(directiveInjector != null);
50-
if (nodes == null) nodes = cloneElements(templateElements);
51-
var timerId;
52-
try {
53-
assert((timerId = _perf.startTimer('ng.view')) != false);
54-
EventHandler eventHandler = directiveInjector.getByKey(EVENT_HANDLER_KEY);
55-
Animate animate = directiveInjector.getByKey(ANIMATE_KEY);
56-
var view = new View(nodes, scope, eventHandler);
57-
_link(view, scope, nodes, elementBinders, eventHandler, animate, directiveInjector);
58-
return view;
59-
} finally {
60-
assert(_perf.stopTimer(timerId) != false);
61-
}
62-
}
63-
64-
View _link(View view, Scope scope, List<dom.Node> nodeList, List elementBinders,
65-
EventHandler eventHandler, Animate animate,
66-
DirectiveInjector directiveInjector) {
67-
68-
var preRenderedIndexOffset = 0;
69-
var directiveDefsByName = {};
70-
71-
for (int i = 0; i < elementBinders.length; i++) {
72-
// querySelectorAll('.ng-binding') should return a list of nodes in the
73-
// same order as the elementBinders list.
74-
75-
// keep a injector array --
76-
77-
var eb = elementBinders[i];
78-
int index = eb.offsetIndex;
79-
80-
ElementBinderTree tree = eb.subtree;
81-
82-
//List childElementBinders = eb.childElementBinders;
83-
int nodeListIndex = index + preRenderedIndexOffset;
84-
dom.Node node = nodeList[nodeListIndex];
85-
var binder = tree.binder;
86-
87-
var timerId;
88-
try {
89-
assert((timerId = _perf.startTimer('ng.view.link', _html(node))) != false);
90-
// if node isn't attached to the DOM, create a parent for it.
91-
var parentNode = node.parentNode;
92-
var fakeParent = false;
93-
if (parentNode == null) {
94-
fakeParent = true;
95-
parentNode = new dom.DivElement()..append(node);
96-
}
97-
98-
DirectiveInjector childInjector;
99-
if (binder == null) {
100-
childInjector = directiveInjector;
101-
} else {
102-
childInjector = binder.bind(view, scope, directiveInjector, node, eventHandler, animate);
103-
104-
// TODO(misko): Remove this after we remove controllers. No controllers -> 1to1 Scope:View.
105-
if (childInjector != directiveInjector) scope = childInjector.scope;
106-
}
107-
if (fakeParent) {
108-
// extract the node from the parentNode.
109-
nodeList[nodeListIndex] = parentNode.nodes[0];
110-
}
111-
112-
if (tree.subtrees != null) {
113-
_link(view, scope, node.nodes, tree.subtrees, eventHandler, animate, childInjector);
114-
}
115-
} finally {
116-
assert(_perf.stopTimer(timerId) != false);
117-
}
118-
}
119-
return view;
120-
}
121-
}
122-
12329
/**
12430
* ViewCache is used to cache the compilation of templates into [View]s.
12531
* It can be used synchronously if HTML is known or asynchronously if the

lib/core_dom/walking_compiler.dart

Lines changed: 0 additions & 111 deletions
This file was deleted.

test/core_dom/compiler_spec.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ import 'package:angular/core_dom/directive_injector.dart';
55

66

77
forBothCompilers(fn) {
8-
describe('walking compiler', () {
9-
beforeEachModule((Module m) {
10-
m.bind(Compiler, toImplementation: WalkingCompiler);
11-
return m;
12-
});
13-
fn('walking');
14-
});
15-
168
describe('tagging compiler', () {
179
beforeEachModule((Module m) {
1810
m.bind(Compiler, toImplementation: TaggingCompiler);

test/core_dom/view_spec.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ library view_spec;
22

33
import '../_specs.dart';
44
import 'package:angular/application_factory.dart';
5+
import 'package:angular/core_dom/static_keys.dart';
56

67
class Log {
78
List<String> log = <String>[];
@@ -61,7 +62,6 @@ class BFormatter {
6162

6263

6364
main() {
64-
var viewFactoryFactory = (a,b,c,d) => new WalkingViewFactory(a,b,c,d);
6565
describe('View', () {
6666
ViewPort viewPort;
6767
Element rootElement;
@@ -73,15 +73,20 @@ main() {
7373

7474
describe('mutation', () {
7575
var a, b;
76-
var expando = new Expando();
76+
77+
View createView(Injector injector, String html) {
78+
final scope = injector.get(Scope);
79+
final c = injector.get(Compiler);
80+
return c(es(html), injector.get(DirectiveMap))(scope, injector.get(DirectiveInjector));
81+
}
7782

7883
beforeEach((Injector injector, Profiler perf) {
7984
rootElement.innerHtml = '<!-- anchor -->';
8085
var scope = injector.get(Scope);
8186
viewPort = new ViewPort(injector.get(DirectiveInjector), scope, rootElement.childNodes[0],
8287
injector.get(Animate));
83-
a = (viewFactoryFactory(es('<span>A</span>a'), [], perf, expando))(scope, injector.get(DirectiveInjector));
84-
b = (viewFactoryFactory(es('<span>B</span>b'), [], perf, expando))(scope, injector.get(DirectiveInjector));
88+
a = createView(injector, "<span>A</span>a");
89+
b = createView(injector, "<span>B</span>b");
8590
});
8691

8792

0 commit comments

Comments
 (0)