refactor(view): remove hostActions

BREAKING CHANGE

Closes #3396

Replacement. Either direct DOM access or Renderer in WebWorkers.
This commit is contained in:
Misko Hevery
2015-08-26 13:55:53 -07:00
parent 37b042b361
commit ac3f5106e4
14 changed files with 13 additions and 185 deletions

View File

@ -214,12 +214,6 @@ export class DirectiveBinding extends ResolvedBinding {
return isPresent(this.metadata) && isPresent(this.metadata.events) ? this.metadata.events : [];
}
get hostActions(): Map<string, string> {
return isPresent(this.metadata) && isPresent(this.metadata.hostActions) ?
this.metadata.hostActions :
new Map();
}
get changeDetection() { return this.metadata.changeDetection; }
static createFromBinding(binding: Binding, ann: DirectiveMetadata): DirectiveBinding {
@ -312,22 +306,10 @@ function _createEventEmitterAccessors(bwv: BindingWithVisibility): EventEmitterA
});
}
function _createHostActionAccessors(bwv: BindingWithVisibility): HostActionAccessor[] {
var binding = bwv.binding;
if (!(binding instanceof DirectiveBinding)) return [];
var res = [];
var db = <DirectiveBinding>binding;
MapWrapper.forEach(db.hostActions, (actionExpression, actionName) => {
res.push(new HostActionAccessor(actionExpression, reflector.getter(actionName)));
});
return res;
}
export class ProtoElementInjector {
view: viewModule.AppView;
attributes: Map<string, string>;
eventEmitterAccessors: List<List<EventEmitterAccessor>>;
hostActionAccessors: List<List<HostActionAccessor>>;
protoInjector: ProtoInjector;
static create(parent: ProtoElementInjector, index: number, bindings: List<ResolvedBinding>,
@ -386,15 +368,10 @@ export class ProtoElementInjector {
public _firstBindingIsComponent: boolean,
public directiveVariableBindings: Map<string, number>) {
var length = bwv.length;
this.protoInjector = new ProtoInjector(bwv);
this.eventEmitterAccessors = ListWrapper.createFixedSize(length);
this.hostActionAccessors = ListWrapper.createFixedSize(length);
for (var i = 0; i < length; ++i) {
this.eventEmitterAccessors[i] = _createEventEmitterAccessors(bwv[i]);
this.hostActionAccessors[i] = _createHostActionAccessors(bwv[i]);
}
}
@ -563,10 +540,6 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
return this._proto.eventEmitterAccessors;
}
getHostActionAccessors(): List<List<HostActionAccessor>> {
return this._proto.hostActionAccessors;
}
getDirectiveVariableBindings(): Map<string, number> {
return this._proto.directiveVariableBindings;
}

View File

@ -211,7 +211,6 @@ export class AppViewManagerUtils {
currView.preBuiltObjects[boundElementIndex]);
this._populateViewLocals(currView, elementInjector, boundElementIndex);
this._setUpEventEmitters(currView, elementInjector, boundElementIndex);
this._setUpHostActions(currView, elementInjector, boundElementIndex);
}
}
var pipes = isPresent(hostElementInjector) ?
@ -250,20 +249,6 @@ export class AppViewManagerUtils {
}
}
_setUpHostActions(view: viewModule.AppView, elementInjector: eli.ElementInjector,
boundElementIndex: number) {
var hostActions = elementInjector.getHostActionAccessors();
for (var directiveIndex = 0; directiveIndex < hostActions.length; ++directiveIndex) {
var directiveHostActions = hostActions[directiveIndex];
var directive = elementInjector.getDirectiveAtIndex(directiveIndex);
for (var index = 0; index < directiveHostActions.length; ++index) {
var hostActionAccessor = directiveHostActions[index];
hostActionAccessor.subscribe(view, boundElementIndex, directive);
}
}
}
dehydrateView(initView: viewModule.AppView) {
var endViewOffset = initView.viewOffset +
initView.mainMergeMapping.nestedViewCountByViewIndex[initView.viewOffset];