diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-05-16 00:24:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 00:24:42 +0300 |
commit | d574ba7090b2e3444c1a631d6e14279854961439 (patch) | |
tree | 491ca190633c3e7bbe2be04bd152e2e98906be12 /plugins | |
parent | 0bd72e797bd418dfcf207f76aa00ffb1278bd5ec (diff) |
correctly destroy vue entry components in widgetloader (#19216)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreHome/vue/dist/CoreHome.umd.js | 29 | ||||
-rw-r--r-- | plugins/CoreHome/vue/dist/CoreHome.umd.min.js | 2 | ||||
-rw-r--r-- | plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue | 9 |
3 files changed, 21 insertions, 19 deletions
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js index 2fff902ec6..42354451cf 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js @@ -9682,33 +9682,33 @@ window.angular.module('piwikApp.service').factory('reportMetadataModel', functio } }; }); -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue?vue&type=template&id=5b8231c3 +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue?vue&type=template&id=2dfca834 -var WidgetLoadervue_type_template_id_5b8231c3_hoisted_1 = { +var WidgetLoadervue_type_template_id_2dfca834_hoisted_1 = { key: 0 }; -var WidgetLoadervue_type_template_id_5b8231c3_hoisted_2 = { +var WidgetLoadervue_type_template_id_2dfca834_hoisted_2 = { class: "notification system notification-error" }; -var WidgetLoadervue_type_template_id_5b8231c3_hoisted_3 = { +var WidgetLoadervue_type_template_id_2dfca834_hoisted_3 = { key: 0, rel: "noreferrer noopener", target: "_blank", href: "https://matomo.org/faq/troubleshooting/faq_19489/" }; -var WidgetLoadervue_type_template_id_5b8231c3_hoisted_4 = { +var WidgetLoadervue_type_template_id_2dfca834_hoisted_4 = { class: "theWidgetContent", ref: "widgetContent" }; -function WidgetLoadervue_type_template_id_5b8231c3_render(_ctx, _cache, $props, $setup, $data, $options) { +function WidgetLoadervue_type_template_id_2dfca834_render(_ctx, _cache, $props, $setup, $data, $options) { var _component_ActivityIndicator = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ActivityIndicator"); return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ActivityIndicator, { "loading-message": _ctx.loadingMessage, loading: _ctx.loading - }, null, 8, ["loading-message", "loading"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [_ctx.widgetName ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("h2", WidgetLoadervue_type_template_id_5b8231c3_hoisted_1, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.widgetName), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", WidgetLoadervue_type_template_id_5b8231c3_hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ErrorRequest', '', '')) + " ", 1), _ctx.hasErrorFaqLink ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", WidgetLoadervue_type_template_id_5b8231c3_hoisted_3, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ErrorRequestFaqLink')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.loadingFailed]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", WidgetLoadervue_type_template_id_5b8231c3_hoisted_4, null, 512)]); + }, null, 8, ["loading-message", "loading"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [_ctx.widgetName ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("h2", WidgetLoadervue_type_template_id_2dfca834_hoisted_1, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.widgetName), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", WidgetLoadervue_type_template_id_2dfca834_hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ErrorRequest', '', '')) + " ", 1), _ctx.hasErrorFaqLink ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", WidgetLoadervue_type_template_id_2dfca834_hoisted_3, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ErrorRequestFaqLink')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.loadingFailed]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", WidgetLoadervue_type_template_id_2dfca834_hoisted_4, null, 512)]); } -// CONCATENATED MODULE: ./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue?vue&type=template&id=5b8231c3 +// CONCATENATED MODULE: ./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue?vue&type=template&id=2dfca834 // CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue?vue&type=script&lang=ts @@ -9775,7 +9775,7 @@ function WidgetLoadervue_type_template_id_5b8231c3_render(_ctx, _cache, $props, this.loadWidgetUrl(this.widgetParams, this.changeCounter += 1); } }, - unmounted: function unmounted() { + beforeUnmount: function beforeUnmount() { this.cleanupLastWidgetContent(); }, methods: { @@ -9787,14 +9787,15 @@ function WidgetLoadervue_type_template_id_5b8231c3_render(_ctx, _cache, $props, }, cleanupLastWidgetContent: function cleanupLastWidgetContent() { var widgetContent = this.$refs.widgetContent; - - if (widgetContent) { - widgetContent.innerHTML = ''; - } + Matomo_Matomo.helper.destroyVueComponent(widgetContent); if (this.currentScope) { this.currentScope.$destroy(); } + + if (widgetContent) { + widgetContent.innerHTML = ''; + } }, getWidgetUrl: function getWidgetUrl(parameters) { var urlParams = src_MatomoUrl_MatomoUrl.parsed.value; @@ -9922,7 +9923,7 @@ function WidgetLoadervue_type_template_id_5b8231c3_render(_ctx, _cache, $props, -WidgetLoadervue_type_script_lang_ts.render = WidgetLoadervue_type_template_id_5b8231c3_render +WidgetLoadervue_type_script_lang_ts.render = WidgetLoadervue_type_template_id_2dfca834_render /* harmony default export */ var WidgetLoader = (WidgetLoadervue_type_script_lang_ts); // CONCATENATED MODULE: ./plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.adapter.ts diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js index 1f7a65da6c..1cdbf9308e 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js @@ -461,7 +461,7 @@ function nc(){return{get pages(){return El.pages.value},findPageInCategory:funct * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -window.angular.module("piwikApp.service").factory("reportMetadataModel",(function(){return{get reports(){return cc.reports.value},findReport:cc.findReport.bind(cc),fetchReportMetadata:function(){return cc.fetchReportMetadata().then((function(e){return Dt(e)}))}}}));var sc={key:0},uc={class:"notification system notification-error"},dc={key:0,rel:"noreferrer noopener",target:"_blank",href:"https://matomo.org/faq/troubleshooting/faq_19489/"},pc={class:"theWidgetContent",ref:"widgetContent"};function mc(e,t,n,r,i,o){var l=Object(a["resolveComponent"])("ActivityIndicator");return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",null,[Object(a["createVNode"])(l,{"loading-message":e.loadingMessage,loading:e.loading},null,8,["loading-message","loading"]),Object(a["withDirectives"])(Object(a["createElementVNode"])("div",null,[e.widgetName?(Object(a["openBlock"])(),Object(a["createElementBlock"])("h2",sc,Object(a["toDisplayString"])(e.widgetName),1)):Object(a["createCommentVNode"])("",!0),Object(a["createElementVNode"])("div",uc,[Object(a["createTextVNode"])(Object(a["toDisplayString"])(e.translate("General_ErrorRequest","",""))+" ",1),e.hasErrorFaqLink?(Object(a["openBlock"])(),Object(a["createElementBlock"])("a",dc,Object(a["toDisplayString"])(e.translate("General_ErrorRequestFaqLink")),1)):Object(a["createCommentVNode"])("",!0)])],512),[[a["vShow"],e.loadingFailed]]),Object(a["createElementVNode"])("div",pc,null,512)])}var fc=Object(a["defineComponent"])({props:{widgetParams:Object,widgetName:String},components:{ActivityIndicator:go},data:function(){return{loading:!1,loadingFailed:!1,changeCounter:0,currentScope:null,lastWidgetAbortController:null}},watch:{widgetParams:function(e){e&&this.loadWidgetUrl(e,this.changeCounter+=1)}},computed:{loadingMessage:function(){return this.widgetName?C("General_LoadingPopover",this.widgetName):C("General_LoadingData")},hasErrorFaqLink:function(){var e=S.config.enable_general_settings_admin,t=S.config.enable_plugins_admin;return S.hasSuperUserAccess&&(e||t)}},mounted:function(){this.widgetParams&&this.loadWidgetUrl(this.widgetParams,this.changeCounter+=1)},unmounted:function(){this.cleanupLastWidgetContent()},methods:{abortHttpRequestIfNeeded:function(){this.lastWidgetAbortController&&(this.lastWidgetAbortController.abort(),this.lastWidgetAbortController=null)},cleanupLastWidgetContent:function(){var e=this.$refs.widgetContent;e&&(e.innerHTML=""),this.currentScope&&this.currentScope.$destroy()},getWidgetUrl:function(e){var t=Ee.parsed.value,n=Object.assign({},e||{}),r=Object.keys(Object.assign(Object.assign({},Ee.hashParsed.value),{},{idSite:"",period:"",date:"",segment:"",widget:""}));return r.forEach((function(e){"category"!==e&&"subcategory"!==e&&(e in n||(n[e]=t[e]))})),jr.isComparisonEnabled()&&(n=Object.assign(Object.assign({},n),{},{comparePeriods:t.comparePeriods,compareDates:t.compareDates,compareSegments:t.compareSegments})),e&&"showtitle"in e||(n.showtitle="1"),S.shouldPropagateTokenAuth&&t.token_auth&&(S.broadcast.isWidgetizeRequestWithoutSession()||(n.force_api_session="1"),n.token_auth=t.token_auth),n.random=Math.floor(1e4*Math.random()),n},loadWidgetUrl:function(e,t){var n=this;this.loading=!0,this.abortHttpRequestIfNeeded(),this.cleanupLastWidgetContent(),this.lastWidgetAbortController=new AbortController,Ze.fetch(this.getWidgetUrl(e),{format:"html",headers:{"X-Requested-With":"XMLHttpRequest"},abortController:this.lastWidgetAbortController}).then((function(r){if(t===n.changeCounter&&r&&"string"===typeof r){n.lastWidgetAbortController=null,n.loading=!1,n.loadingFailed=!1;var i=n.$refs.widgetContent;window.$(i).html(r);var a=window.$(i).children();if(n.widgetName){var o=a.find("> .card-content .card-title");o.length||(o=a.find("> h2")),o.length&&o.html(S.helper.htmlEntities(n.widgetName))}var l=S.helper.getAngularDependency("$rootScope"),c=l.$new();n.currentScope=c,S.helper.compileAngularComponents(a,{scope:c}),S.helper.compileVueEntryComponents(a),hl.parseNotificationDivs(),setTimeout((function(){S.postEvent("widget:loaded",{parameters:e,element:a})}))}})).catch((function(e){t===n.changeCounter&&(n.lastWidgetAbortController=null,n.cleanupLastWidgetContent(),n.loading=!1,"abort"!==e.xhrStatus&&(n.loadingFailed=!0))}))}}});fc.render=mc;var hc=fc; +window.angular.module("piwikApp.service").factory("reportMetadataModel",(function(){return{get reports(){return cc.reports.value},findReport:cc.findReport.bind(cc),fetchReportMetadata:function(){return cc.fetchReportMetadata().then((function(e){return Dt(e)}))}}}));var sc={key:0},uc={class:"notification system notification-error"},dc={key:0,rel:"noreferrer noopener",target:"_blank",href:"https://matomo.org/faq/troubleshooting/faq_19489/"},pc={class:"theWidgetContent",ref:"widgetContent"};function mc(e,t,n,r,i,o){var l=Object(a["resolveComponent"])("ActivityIndicator");return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",null,[Object(a["createVNode"])(l,{"loading-message":e.loadingMessage,loading:e.loading},null,8,["loading-message","loading"]),Object(a["withDirectives"])(Object(a["createElementVNode"])("div",null,[e.widgetName?(Object(a["openBlock"])(),Object(a["createElementBlock"])("h2",sc,Object(a["toDisplayString"])(e.widgetName),1)):Object(a["createCommentVNode"])("",!0),Object(a["createElementVNode"])("div",uc,[Object(a["createTextVNode"])(Object(a["toDisplayString"])(e.translate("General_ErrorRequest","",""))+" ",1),e.hasErrorFaqLink?(Object(a["openBlock"])(),Object(a["createElementBlock"])("a",dc,Object(a["toDisplayString"])(e.translate("General_ErrorRequestFaqLink")),1)):Object(a["createCommentVNode"])("",!0)])],512),[[a["vShow"],e.loadingFailed]]),Object(a["createElementVNode"])("div",pc,null,512)])}var fc=Object(a["defineComponent"])({props:{widgetParams:Object,widgetName:String},components:{ActivityIndicator:go},data:function(){return{loading:!1,loadingFailed:!1,changeCounter:0,currentScope:null,lastWidgetAbortController:null}},watch:{widgetParams:function(e){e&&this.loadWidgetUrl(e,this.changeCounter+=1)}},computed:{loadingMessage:function(){return this.widgetName?C("General_LoadingPopover",this.widgetName):C("General_LoadingData")},hasErrorFaqLink:function(){var e=S.config.enable_general_settings_admin,t=S.config.enable_plugins_admin;return S.hasSuperUserAccess&&(e||t)}},mounted:function(){this.widgetParams&&this.loadWidgetUrl(this.widgetParams,this.changeCounter+=1)},beforeUnmount:function(){this.cleanupLastWidgetContent()},methods:{abortHttpRequestIfNeeded:function(){this.lastWidgetAbortController&&(this.lastWidgetAbortController.abort(),this.lastWidgetAbortController=null)},cleanupLastWidgetContent:function(){var e=this.$refs.widgetContent;S.helper.destroyVueComponent(e),this.currentScope&&this.currentScope.$destroy(),e&&(e.innerHTML="")},getWidgetUrl:function(e){var t=Ee.parsed.value,n=Object.assign({},e||{}),r=Object.keys(Object.assign(Object.assign({},Ee.hashParsed.value),{},{idSite:"",period:"",date:"",segment:"",widget:""}));return r.forEach((function(e){"category"!==e&&"subcategory"!==e&&(e in n||(n[e]=t[e]))})),jr.isComparisonEnabled()&&(n=Object.assign(Object.assign({},n),{},{comparePeriods:t.comparePeriods,compareDates:t.compareDates,compareSegments:t.compareSegments})),e&&"showtitle"in e||(n.showtitle="1"),S.shouldPropagateTokenAuth&&t.token_auth&&(S.broadcast.isWidgetizeRequestWithoutSession()||(n.force_api_session="1"),n.token_auth=t.token_auth),n.random=Math.floor(1e4*Math.random()),n},loadWidgetUrl:function(e,t){var n=this;this.loading=!0,this.abortHttpRequestIfNeeded(),this.cleanupLastWidgetContent(),this.lastWidgetAbortController=new AbortController,Ze.fetch(this.getWidgetUrl(e),{format:"html",headers:{"X-Requested-With":"XMLHttpRequest"},abortController:this.lastWidgetAbortController}).then((function(r){if(t===n.changeCounter&&r&&"string"===typeof r){n.lastWidgetAbortController=null,n.loading=!1,n.loadingFailed=!1;var i=n.$refs.widgetContent;window.$(i).html(r);var a=window.$(i).children();if(n.widgetName){var o=a.find("> .card-content .card-title");o.length||(o=a.find("> h2")),o.length&&o.html(S.helper.htmlEntities(n.widgetName))}var l=S.helper.getAngularDependency("$rootScope"),c=l.$new();n.currentScope=c,S.helper.compileAngularComponents(a,{scope:c}),S.helper.compileVueEntryComponents(a),hl.parseNotificationDivs(),setTimeout((function(){S.postEvent("widget:loaded",{parameters:e,element:a})}))}})).catch((function(e){t===n.changeCounter&&(n.lastWidgetAbortController=null,n.cleanupLastWidgetContent(),n.loading=!1,"abort"!==e.xhrStatus&&(n.loadingFailed=!0))}))}}});fc.render=mc;var hc=fc; /*! * Matomo - free/libre analytics platform * diff --git a/plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue b/plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue index 2d1eeea6a7..7b42c8ab1c 100644 --- a/plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue +++ b/plugins/CoreHome/vue/src/WidgetLoader/WidgetLoader.vue @@ -105,7 +105,7 @@ export default defineComponent({ this.loadWidgetUrl(this.widgetParams as QueryParameters, this.changeCounter += 1); } }, - unmounted() { + beforeUnmount() { this.cleanupLastWidgetContent(); }, methods: { @@ -117,12 +117,13 @@ export default defineComponent({ }, cleanupLastWidgetContent() { const widgetContent = this.$refs.widgetContent as HTMLElement; - if (widgetContent) { - widgetContent.innerHTML = ''; - } + Matomo.helper.destroyVueComponent(widgetContent); if (this.currentScope) { this.currentScope.$destroy(); } + if (widgetContent) { + widgetContent.innerHTML = ''; + } }, getWidgetUrl(parameters?: QueryParameters): QueryParameters { const urlParams = MatomoUrl.parsed.value; |