diff --git a/packages/@ember/-internals/glimmer/lib/component.ts b/packages/@ember/-internals/glimmer/lib/component.ts index e49a686f951..8202eacaca9 100644 --- a/packages/@ember/-internals/glimmer/lib/component.ts +++ b/packages/@ember/-internals/glimmer/lib/component.ts @@ -751,6 +751,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + didReceiveAttrs() {}, /** Called when the attributes passed into the component have been updated. @@ -769,6 +770,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + didRender() {}, /** Called after a component has been rendered, both on initial render and @@ -785,6 +787,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + willRender() {}, /** Called before a component has been rendered, both on initial render and @@ -801,6 +804,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + didUpdateAttrs() {}, /** Called when the attributes passed into the component have been changed. @@ -817,6 +821,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + willUpdate() {}, /** Called when the component is about to update and rerender itself. @@ -833,6 +838,7 @@ const Component = CoreView.extend( @public @since 1.13.0 */ + didUpdate() {}, /** Called when the component has updated and rerendered itself. diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/life-cycle-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/life-cycle-test.js index f5108f06452..f2bb98e5127 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/life-cycle-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/life-cycle-test.js @@ -1571,6 +1571,24 @@ moduleFor( ] ); } + + ['@test lifecycle hooks exist on the base class'](assert) { + // Make sure we get the finalized component prototype + let prototype = Component.proto(); + + assert.equal(typeof prototype.didDestroyElement, 'function', 'didDestroyElement exists'); + assert.equal(typeof prototype.didInsertElement, 'function', 'didInsertElement exists'); + assert.equal(typeof prototype.didReceiveAttrs, 'function', 'didReceiveAttrs exists'); + assert.equal(typeof prototype.didRender, 'function', 'didRender exists'); + assert.equal(typeof prototype.didUpdate, 'function', 'didUpdate exists'); + assert.equal(typeof prototype.didUpdateAttrs, 'function', 'didUpdateAttrs exists'); + assert.equal(typeof prototype.willClearRender, 'function', 'willClearRender exists'); + assert.equal(typeof prototype.willDestroy, 'function', 'willDestroy exists'); + assert.equal(typeof prototype.willDestroyElement, 'function', 'willDestroyElement exists'); + assert.equal(typeof prototype.willInsertElement, 'function', 'willInsertElement exists'); + assert.equal(typeof prototype.willRender, 'function', 'willRender exists'); + assert.equal(typeof prototype.willUpdate, 'function', 'willUpdate exists'); + } } ); diff --git a/packages/@ember/-internals/views/lib/mixins/view_support.js b/packages/@ember/-internals/views/lib/mixins/view_support.js index e15096772c7..c5a02f5740c 100644 --- a/packages/@ember/-internals/views/lib/mixins/view_support.js +++ b/packages/@ember/-internals/views/lib/mixins/view_support.js @@ -369,6 +369,14 @@ export default Mixin.create({ */ willDestroyElement: K, + /** + Called after the element of the view is destroyed. + + @event willDestroyElement + @public + */ + didDestroyElement: K, + /** Called when the parentView property has changed.