Skip to content

Commit

Permalink
feature #444 Add Vue app to the vue:mount event (pierredup)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Add Vue app to the vue:mount event

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Tickets       | N/A
| License       | MIT

Add the Vue app to the `vue:mount` event, so that users can have access to it when hooking into the event in order to use [Vue Plugins](https://vuejs.org/guide/reusability/plugins.html#introduction) with components. Without access to the app instance, it's not possible to use plugins.

Commits
-------

86fa0c8 Add Vue app to the vue:mount event
  • Loading branch information
weaverryan committed Sep 16, 2022
2 parents 733cc8b + 86fa0c8 commit 4478325
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Vue/Resources/assets/src/render_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export default class extends Controller<Element & { __vue_app__?: App<Element> }
if (this.element.__vue_app__ !== undefined) {
this.element.__vue_app__.unmount();
}

this._dispatchEvent('vue:before-mount', {
componentName: this.componentValue,
component: component,
props: this.props,
app: this.app,
});

this.app.mount(this.element);

Expand Down

0 comments on commit 4478325

Please sign in to comment.