From 14f9fb0249804ee267c59a52b05c6491ed7f05b8 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 5 Nov 2021 12:07:52 -0700 Subject: [PATCH] Vue: Add propsData parameter to Vue.createMwApp() For compatibility with the createApp() API in Vue 3. Bug: T294476 Change-Id: I1fcdcf7bf87f5af2deb9763a231f2c360ea45b23 --- resources/src/vue/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/src/vue/index.js b/resources/src/vue/index.js index a0cae377ddc..bc440a33c23 100644 --- a/resources/src/vue/index.js +++ b/resources/src/vue/index.js @@ -24,17 +24,25 @@ * To create and mount an app with Vuex: * var RootComponent = require( './RootComponent.vue' ), * store = require( './store.js' ); - * Vue.createMwApp( RootCompoinent ) + * Vue.createMwApp( RootComponent ) * .use( store ) * .mount( '#foo' ); * + * To pass props to the component, pass them as the second parameter to createMwApp(): + * Vue.createMwApp( RootComponent, { pageName: 'foo', disabled: false } ); + * * @param {Object} componentOptions Vue component options object + * @param {Object} [propsData] Props to pass to the component * @return {Object} Object that pretends to be a Vue 3 app object, supports .use() and .mount() */ - Vue.createMwApp = function ( componentOptions ) { + Vue.createMwApp = function ( componentOptions, propsData ) { var App = Vue.extend( componentOptions ), finalOptions = {}; + if ( propsData ) { + finalOptions.propsData = propsData; + } + // Wrap .use(), so we can redirect app.use( VuexStore ) App.use = function ( plugin ) { if (