diff --git a/index.js b/index.js index cb8910c..f85294f 100644 --- a/index.js +++ b/index.js @@ -99,15 +99,7 @@ function getComputedWatcher(name, fn) { function getComponentContext(instance) { return { - el() { - return instance.el; - }, - owner() { - return instance.owner; - }, - parentComponent() { - return instance.parentComponent; - }, + instance, dispatch(...args) { instance.dispatch.apply(instance, args); }, diff --git a/test/lifeCycle.spec.js b/test/lifeCycle.spec.js index ec4af4c..1e8fcac 100644 --- a/test/lifeCycle.spec.js +++ b/test/lifeCycle.spec.js @@ -234,10 +234,10 @@ describe('[life cycle]: ', () => { onConstruct(function (options) { expect(options.from).toBe('err'); - // expect(typeof context.template).toBe('string'); - // expect(context.data).toBeUndefined(); - // expect(context.scope).toBeUndefined(); - expect(context.owner()).toBeUndefined(); + expect(typeof context.instance.template).toBe('string'); + expect(context.instance.data).toBeUndefined(); + expect(context.instance.scope).toBeUndefined(); + expect(context.instance.owner).toBeUndefined(); }); }); @@ -342,12 +342,12 @@ describe('[life cycle]: ', () => { }); onCreated(function () { - expect(context.el().tagName).toBe('U'); + expect(context.instance.el.tagName).toBe('U'); uState.created = 1; }); onAttached(function () { - expect(context.el().tagName).toBe('U'); + expect(context.instance.el.tagName).toBe('U'); uState.attached = 1; }); @@ -377,12 +377,12 @@ describe('[life cycle]: ', () => { }) onCreated(function () { - expect(context.el().tagName).toBe('B'); + expect(context.instance.el.tagName).toBe('B'); mainState.created = 1; }) onAttached(function () { - expect(context.el().tagName).toBe('B'); + expect(context.instance.el.tagName).toBe('B'); mainState.attached = 1; }); diff --git a/test/messages.spec.js b/test/messages.spec.js index ab29c10..df1e64a 100644 --- a/test/messages.spec.js +++ b/test/messages.spec.js @@ -48,7 +48,7 @@ describe('[messages]: ', () => { }); onAttached(function () { - item = context.el(); + item = context.instance.el; context.dispatch('UI:select-item-attached'); }); @@ -155,7 +155,7 @@ describe('[messages]: ', () => { }); onAttached(function () { - item = context.el(); + item = context.instance.el; context.dispatch('UI:select-item-attached'); }); @@ -276,7 +276,7 @@ describe('[messages]: ', () => { }); onAttached(function () { - item = context.el(); + item = context.instance.el; context.dispatch('UI:select-item-attached'); }); diff --git a/types/index.d.ts b/types/index.d.ts index b7b52fa..0b8a587 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,9 +3,7 @@ interface DataObj { [key: string]: any; } interface ComponentContext { - el(): Component['el']; - owner(): Component | undefined; - parentComponent(): Component['parentComponent']; + instance: Component; dispatch: Component['dispatch']; fire: Component['fire']; ref: Component['ref'];