diff --git a/modules/angular2/src/core/compiler/element_injector.ts b/modules/angular2/src/core/compiler/element_injector.ts index 3c882957bc..94a784d7f3 100644 --- a/modules/angular2/src/core/compiler/element_injector.ts +++ b/modules/angular2/src/core/compiler/element_injector.ts @@ -214,12 +214,6 @@ export class DirectiveBinding extends ResolvedBinding { return isPresent(this.metadata) && isPresent(this.metadata.events) ? this.metadata.events : []; } - get hostActions(): Map { - 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 = 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; eventEmitterAccessors: List>; - hostActionAccessors: List>; protoInjector: ProtoInjector; static create(parent: ProtoElementInjector, index: number, bindings: List, @@ -386,15 +368,10 @@ export class ProtoElementInjector { public _firstBindingIsComponent: boolean, public directiveVariableBindings: Map) { 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 implements Depend return this._proto.eventEmitterAccessors; } - getHostActionAccessors(): List> { - return this._proto.hostActionAccessors; - } - getDirectiveVariableBindings(): Map { return this._proto.directiveVariableBindings; } diff --git a/modules/angular2/src/core/compiler/view_manager_utils.ts b/modules/angular2/src/core/compiler/view_manager_utils.ts index e26649b075..b7576f7503 100644 --- a/modules/angular2/src/core/compiler/view_manager_utils.ts +++ b/modules/angular2/src/core/compiler/view_manager_utils.ts @@ -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]; diff --git a/modules/angular2/src/core/metadata/directives.ts b/modules/angular2/src/core/metadata/directives.ts index 5c24d4c686..73df44773b 100644 --- a/modules/angular2/src/core/metadata/directives.ts +++ b/modules/angular2/src/core/metadata/directives.ts @@ -628,31 +628,6 @@ export class DirectiveMetadata extends InjectableMetadata { * In this example using `my-button` directive (ex.: `
`) on a host element * (here: `
` ) will ensure that this element will get the "button" role. * - * ## Actions - * - * Specifies which DOM methods a directive can invoke. - * - * ## Syntax - * - * ``` - * @Directive({ - * selector: 'input', - * host: { - * '@emitFocus': 'focus()' - * } - * }) - * class InputDirective { - * constructor() { - * this.emitFocus = new EventEmitter(); - * } - * - * focus() { - * this.emitFocus.next(); - * } - * } - * ``` - * - * In this example calling focus on InputDirective will result in calling focus on the input. */ host: StringMap; diff --git a/modules/angular2/src/core/render/api.ts b/modules/angular2/src/core/render/api.ts index 324fbe46eb..31270cfd86 100644 --- a/modules/angular2/src/core/render/api.ts +++ b/modules/angular2/src/core/render/api.ts @@ -163,15 +163,13 @@ export class RenderDirectiveMetadata { hostListeners: Map; hostProperties: Map; hostAttributes: Map; - hostActions: Map; // group 1: "property" from "[property]" // group 2: "event" from "(event)" - // group 3: "action" from "@action" - private static _hostRegExp = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\))|(?:@(.+)))$/g; + private static _hostRegExp = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g; constructor({id, selector, compileChildren, events, hostListeners, hostProperties, hostAttributes, - hostActions, properties, readAttributes, type, callOnDestroy, callOnChange, - callOnCheck, callOnInit, callOnAllChangesDone, changeDetection, exportAs}: { + properties, readAttributes, type, callOnDestroy, callOnChange, callOnCheck, + callOnInit, callOnAllChangesDone, changeDetection, exportAs}: { id?: string, selector?: string, compileChildren?: boolean, @@ -179,7 +177,6 @@ export class RenderDirectiveMetadata { hostListeners?: Map, hostProperties?: Map, hostAttributes?: Map, - hostActions?: Map, properties?: List, readAttributes?: List, type?: number, @@ -198,7 +195,6 @@ export class RenderDirectiveMetadata { this.hostListeners = hostListeners; this.hostAttributes = hostAttributes; this.hostProperties = hostProperties; - this.hostActions = hostActions; this.properties = properties; this.readAttributes = readAttributes; this.type = type; @@ -233,7 +229,6 @@ export class RenderDirectiveMetadata { let hostListeners = new Map(); let hostProperties = new Map(); let hostAttributes = new Map(); - let hostActions = new Map(); if (isPresent(host)) { MapWrapper.forEach(host, (value: string, key: string) => { @@ -244,8 +239,6 @@ export class RenderDirectiveMetadata { hostProperties.set(matches[1], value); } else if (isPresent(matches[2])) { hostListeners.set(matches[2], value); - } else if (isPresent(matches[3])) { - hostActions.set(matches[3], value); } }); } @@ -258,7 +251,6 @@ export class RenderDirectiveMetadata { hostListeners: hostListeners, hostProperties: hostProperties, hostAttributes: hostAttributes, - hostActions: hostActions, properties: properties, readAttributes: readAttributes, type: type, diff --git a/modules/angular2/src/web_workers/shared/serializer.ts b/modules/angular2/src/web_workers/shared/serializer.ts index f2f1669a47..21a37a850a 100644 --- a/modules/angular2/src/web_workers/shared/serializer.ts +++ b/modules/angular2/src/web_workers/shared/serializer.ts @@ -380,7 +380,6 @@ export class Serializer { 'exportAs': meta.exportAs, 'hostProperties': this.mapToObject(meta.hostProperties), 'hostListeners': this.mapToObject(meta.hostListeners), - 'hostActions': this.mapToObject(meta.hostActions), 'hostAttributes': this.mapToObject(meta.hostAttributes) }; return obj; @@ -392,7 +391,6 @@ export class Serializer { compileChildren: obj['compileChildren'], hostProperties: this.objectToMap(obj['hostProperties']), hostListeners: this.objectToMap(obj['hostListeners']), - hostActions: this.objectToMap(obj['hostActions']), hostAttributes: this.objectToMap(obj['hostAttributes']), properties: obj['properties'], readAttributes: obj['readAttributes'], diff --git a/modules/angular2/test/core/compiler/element_injector_spec.ts b/modules/angular2/test/core/compiler/element_injector_spec.ts index c980a52b59..03ac5516ee 100644 --- a/modules/angular2/test/core/compiler/element_injector_spec.ts +++ b/modules/angular2/test/core/compiler/element_injector_spec.ts @@ -117,11 +117,6 @@ class HasEventEmitter { constructor() { this.emitter = "emitter"; } } -class HasHostAction { - hostActionName; - constructor() { this.hostActionName = "hostAction"; } -} - class NeedsAttribute { typeAttribute; titleAttribute; @@ -433,18 +428,6 @@ export function main() { expect(accessor.eventName).toEqual('publicEmitter'); expect(accessor.getter(new HasEventEmitter())).toEqual('emitter'); }); - - it('should return a list of hostAction accessors', () => { - var binding = DirectiveBinding.createFromType( - HasEventEmitter, new DirectiveMetadata({host: {'@hostActionName': 'onAction'}})); - - var inj = createPei(null, 0, [binding]); - expect(inj.hostActionAccessors.length).toEqual(1); - - var accessor = inj.hostActionAccessors[0][0]; - expect(accessor.methodName).toEqual('onAction'); - expect(accessor.getter(new HasHostAction())).toEqual('hostAction'); - }); }); describe(".create", () => { diff --git a/modules/angular2/test/core/compiler/integration_spec.ts b/modules/angular2/test/core/compiler/integration_spec.ts index 0b41161292..13ca2a012e 100644 --- a/modules/angular2/test/core/compiler/integration_spec.ts +++ b/modules/angular2/test/core/compiler/integration_spec.ts @@ -841,31 +841,6 @@ export function main() { }); })); - if (DOM.supportsDOMEvents()) { - it("should support invoking methods on the host element via hostActions", - inject( - [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { - tcb.overrideView(MyComp, new ViewMetadata({ - template: '
', - directives: [DirectiveUpdatingHostActions] - })) - - .createAsync(MyComp) - .then((rootTC) => { - var tc = rootTC.componentViewChildren[0]; - var nativeElement = tc.nativeElement; - var updateHost = tc.inject(DirectiveUpdatingHostActions); - - ObservableWrapper.subscribe(updateHost.setAttr, (_) => { - expect(DOM.hasAttribute(nativeElement, 'update-host-actions')).toBe(true); - async.done(); - }); - - updateHost.triggerSetAttr('value'); - }); - })); - } - it('should support render events', inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { tcb.overrideView( diff --git a/modules/angular2/test/core/compiler/view_manager_utils_spec.ts b/modules/angular2/test/core/compiler/view_manager_utils_spec.ts index 5dea03f3be..40c2c0534c 100644 --- a/modules/angular2/test/core/compiler/view_manager_utils_spec.ts +++ b/modules/angular2/test/core/compiler/view_manager_utils_spec.ts @@ -87,17 +87,13 @@ export function main() { createHostPv([createNestedElBinder(createComponentPv()), createEmptyElBinder()]); var hostView = createViewWithChildren(hostPv); var spyEventAccessor1 = SpyObject.stub({"subscribe": null}); - SpyObject.stub(hostView.elementInjectors[0], { - 'getHostActionAccessors': [], - 'getEventEmitterAccessors': [[spyEventAccessor1]], - 'getDirectiveAtIndex': dir - }); + SpyObject.stub( + hostView.elementInjectors[0], + {'getEventEmitterAccessors': [[spyEventAccessor1]], 'getDirectiveAtIndex': dir}); var spyEventAccessor2 = SpyObject.stub({"subscribe": null}); - SpyObject.stub(hostView.elementInjectors[1], { - 'getHostActionAccessors': [], - 'getEventEmitterAccessors': [[spyEventAccessor2]], - 'getDirectiveAtIndex': dir - }); + SpyObject.stub( + hostView.elementInjectors[1], + {'getEventEmitterAccessors': [[spyEventAccessor2]], 'getDirectiveAtIndex': dir}); utils.hydrateRootHostView(hostView, createInjector()); @@ -105,31 +101,6 @@ export function main() { expect(spyEventAccessor2.spy('subscribe')).toHaveBeenCalledWith(hostView, 1, dir); }); - it("should set up host action listeners", () => { - var dir = new Object(); - - var hostPv = - createHostPv([createNestedElBinder(createComponentPv()), createEmptyElBinder()]); - var hostView = createViewWithChildren(hostPv); - var spyActionAccessor1 = SpyObject.stub({"subscribe": null}); - SpyObject.stub(hostView.elementInjectors[0], { - 'getHostActionAccessors': [[spyActionAccessor1]], - 'getEventEmitterAccessors': [], - 'getDirectiveAtIndex': dir - }); - var spyActionAccessor2 = SpyObject.stub({"subscribe": null}); - SpyObject.stub(hostView.elementInjectors[1], { - 'getHostActionAccessors': [[spyActionAccessor2]], - 'getEventEmitterAccessors': [], - 'getDirectiveAtIndex': dir - }); - - utils.hydrateRootHostView(hostView, createInjector()); - - expect(spyActionAccessor1.spy('subscribe')).toHaveBeenCalledWith(hostView, 0, dir); - expect(spyActionAccessor2.spy('subscribe')).toHaveBeenCalledWith(hostView, 1, dir); - }); - it("should not hydrate element injectors of component views inside of embedded fragments", () => { var hostView = createViewWithChildren(createHostPv([ diff --git a/modules/angular2/test/core/render/api_spec.ts b/modules/angular2/test/core/render/api_spec.ts index f2f9b4bdab..6217264578 100644 --- a/modules/angular2/test/core/render/api_spec.ts +++ b/modules/angular2/test/core/render/api_spec.ts @@ -8,17 +8,12 @@ export function main() { describe('host', () => { it('should parse host configuration', () => { var md = RenderDirectiveMetadata.create({ - host: MapWrapper.createFromPairs([ - ['(event)', 'eventVal'], - ['[prop]', 'propVal'], - ['@action', 'actionVal'], - ['attr', 'attrVal'] - ]) + host: MapWrapper.createFromPairs( + [['(event)', 'eventVal'], ['[prop]', 'propVal'], ['attr', 'attrVal']]) }); expect(md.hostListeners).toEqual(MapWrapper.createFromPairs([['event', 'eventVal']])); expect(md.hostProperties).toEqual(MapWrapper.createFromPairs([['prop', 'propVal']])); - expect(md.hostActions).toEqual(MapWrapper.createFromPairs([['action', 'actionVal']])); expect(md.hostAttributes).toEqual(MapWrapper.createFromPairs([['attr', 'attrVal']])); }); }); diff --git a/modules_dart/transform/test/transform/directive_metadata_extractor/all_tests.dart b/modules_dart/transform/test/transform/directive_metadata_extractor/all_tests.dart index fe01a8ad73..a35d319a51 100644 --- a/modules_dart/transform/test/transform/directive_metadata_extractor/all_tests.dart +++ b/modules_dart/transform/test/transform/directive_metadata_extractor/all_tests.dart @@ -97,11 +97,6 @@ void allTests() { expect(metadata.hostAttributes.length).toBe(1); expect(metadata.hostAttributes).toContain('attName'); expect(metadata.hostAttributes['attName']).toEqual('attValue'); - - expect(metadata.hostActions).toBeNotNull(); - expect(metadata.hostActions.length).toBe(1); - expect(metadata.hostActions).toContain('actionName'); - expect(metadata.hostActions['actionName']).toEqual('actionValue'); }); it('should parse lifecycle events.', () async { diff --git a/modules_dart/transform/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart b/modules_dart/transform/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart index 693b0e0457..cdf2116132 100644 --- a/modules_dart/transform/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart +++ b/modules_dart/transform/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart @@ -15,7 +15,6 @@ void initReflector(reflector) { const Component(host: const { '(change)': 'onChange(\$event)', '[value]': 'value', - '@actionName': 'actionValue', 'attName': 'attValue' }) ], const [ diff --git a/modules_dart/transform/test/transform/integration/simple_annotation_files/expected/bar.ng_meta.json b/modules_dart/transform/test/transform/integration/simple_annotation_files/expected/bar.ng_meta.json index e1b930e04b..7c411384e6 100644 --- a/modules_dart/transform/test/transform/integration/simple_annotation_files/expected/bar.ng_meta.json +++ b/modules_dart/transform/test/transform/integration/simple_annotation_files/expected/bar.ng_meta.json @@ -7,7 +7,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], diff --git a/modules_dart/transform/test/transform/template_compiler/registrations_files/dependency.ng_meta.json b/modules_dart/transform/test/transform/template_compiler/registrations_files/dependency.ng_meta.json index 9c7d08e21f..f202ad6ec1 100644 --- a/modules_dart/transform/test/transform/template_compiler/registrations_files/dependency.ng_meta.json +++ b/modules_dart/transform/test/transform/template_compiler/registrations_files/dependency.ng_meta.json @@ -7,7 +7,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": null, "readAttributes": null, @@ -31,7 +30,6 @@ "compileChildren": true, "hostProperties": {"hprop": "hprop"}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": ["prop"], "readAttributes": null, @@ -55,7 +53,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {"subevent": "doAThing()"}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": null, @@ -79,7 +76,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": ["ngForOf"], "readAttributes": null, @@ -95,4 +91,4 @@ "version": 1 } } -} \ No newline at end of file +} diff --git a/modules_dart/transform/test/transform/template_compiler/registrations_files/registrations.ng_meta.json b/modules_dart/transform/test/transform/template_compiler/registrations_files/registrations.ng_meta.json index f6a72482d2..fb47758d85 100644 --- a/modules_dart/transform/test/transform/template_compiler/registrations_files/registrations.ng_meta.json +++ b/modules_dart/transform/test/transform/template_compiler/registrations_files/registrations.ng_meta.json @@ -7,7 +7,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": null, "readAttributes": null, @@ -31,7 +30,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -55,7 +53,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -79,7 +76,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -103,7 +99,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -127,7 +122,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -151,7 +145,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -175,7 +168,6 @@ "compileChildren": true, "hostProperties": {}, "hostListeners": {}, - "hostActions": {}, "hostAttributes": {}, "properties": [], "readAttributes": [], @@ -191,4 +183,4 @@ "version": 1 } } -} \ No newline at end of file +}