feat(core): speed up view creation via code gen for view factories.
BREAKING CHANGE: - Platform pipes can only contain types and arrays of types, but no bindings any more. - When using transformers, platform pipes need to be specified explicitly in the pubspec.yaml via the new config option `platform_pipes`. - `Compiler.compileInHost` now returns a `HostViewFactoryRef` - Component view is not yet created when component constructor is called. -> use `onInit` lifecycle callback to access the view of a component - `ViewRef#setLocal` has been moved to new type `EmbeddedViewRef` - `internalView` is gone, use `EmbeddedViewRef.rootNodes` to access the root nodes of an embedded view - `renderer.setElementProperty`, `..setElementStyle`, `..setElementAttribute` now take a native element instead of an ElementRef - `Renderer` interface now operates on plain native nodes, instead of `RenderElementRef`s or `RenderViewRef`s Closes #5993
This commit is contained in:
@ -245,13 +245,12 @@ function runBaselineWrites(baselineHead, numberOfRuns, object) {
|
||||
// ---- CHANGE DETECTION
|
||||
|
||||
function setUpChangeDetection(protoChangeDetectorFactory: Function, iterations, object) {
|
||||
var dispatcher = new DummyDispatcher();
|
||||
var parser = new Parser(new Lexer());
|
||||
|
||||
var genConfig = new ChangeDetectorGenConfig(false, false, true);
|
||||
var parentProto = protoChangeDetectorFactory(
|
||||
new ChangeDetectorDefinition('parent', null, [], [], [], [], genConfig));
|
||||
var parentCd = parentProto.instantiate(dispatcher);
|
||||
var parentCd = parentProto.instantiate();
|
||||
|
||||
var directiveRecord = new DirectiveRecord({directiveIndex: new DirectiveIndex(0, 0)});
|
||||
var bindings = [
|
||||
@ -281,10 +280,10 @@ function setUpChangeDetection(protoChangeDetectorFactory: Function, iterations,
|
||||
new ChangeDetectorDefinition("proto", null, [], bindings, [], [directiveRecord], genConfig));
|
||||
|
||||
var targetObj = new Obj();
|
||||
parentCd.hydrate(object, null, new FakeDirectives(targetObj), null);
|
||||
parentCd.hydrate(object, null, new DummyDispatcher(targetObj), null);
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
var cd = proto.instantiate(dispatcher);
|
||||
cd.hydrate(object, null, new FakeDirectives(targetObj), null);
|
||||
var cd = proto.instantiate();
|
||||
cd.hydrate(object, null, new DummyDispatcher(targetObj), null);
|
||||
parentCd.addContentChild(cd);
|
||||
}
|
||||
return parentCd;
|
||||
@ -374,20 +373,17 @@ export function main() {
|
||||
}
|
||||
}
|
||||
|
||||
class FakeDirectives {
|
||||
targetObj: Obj;
|
||||
|
||||
constructor(targetObj) { this.targetObj = targetObj; }
|
||||
|
||||
getDirectiveFor(record) { return this.targetObj; }
|
||||
}
|
||||
|
||||
class DummyDispatcher implements ChangeDispatcher {
|
||||
getDebugContext(elementIndex: number, directiveIndex: DirectiveIndex): DebugContext {
|
||||
targetObj: Obj;
|
||||
constructor(targetObj) { this.targetObj = targetObj; }
|
||||
getDebugContext(appElement: any, elementIndex: number, directiveIndex: number): DebugContext {
|
||||
throw "getDebugContext not implemented.";
|
||||
}
|
||||
notifyOnBinding(bindingTarget, newValue) { throw "Should not be used"; }
|
||||
logBindingUpdate(bindingTarget, newValue) { throw "Should not be used"; }
|
||||
notifyAfterContentChecked() {}
|
||||
notifyAfterViewChecked() {}
|
||||
notifyOnDestroy() {}
|
||||
getDetectorFor(directiveIndex: DirectiveIndex): any { throw "getDetectorFor not implemented."; }
|
||||
getDirectiveFor(record) { return this.targetObj; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user