From 3f35c3e443f068658f6e260805666f6c47cdf186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Tue, 28 May 2019 09:19:10 +0300 Subject: [PATCH] fix multiple root elements on transitio --- dist/vue-wait.js | 2 +- examples/transition-example/main.vue | 2 ++ src/components/v-wait.vue | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/vue-wait.js b/dist/vue-wait.js index 568d814..b53d688 100644 --- a/dist/vue-wait.js +++ b/dist/vue-wait.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueWait=e():t.VueWait=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=r=function(t){return n(t)}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(e)}t.exports=r},function(t,e,n){t.exports=n(16)},function(t,e,n){var r=n(0);t.exports=function(t){for(var e=1;e=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}},function(t,e,n){var r=n(17),i=n(18),o=n(19);t.exports=function(t,e){return r(t)||i(t,e)||o()}},function(t,e,n){t.exports=n(20)},function(t,e){t.exports=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r=0||(i[n]=t[n]);return i}},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;j(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:$(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var r=n(3),i=n.n(r),o=n(6),a=n.n(o),s=n(7),u=n.n(s),c=n(1),f=n.n(c),l=n(8),p=n.n(l),h=n(0),d=n.n(h),v=n(4),y=n.n(v),g=n(15),m=new Map;var w=function(t,e,n){var r=function(t,e){var n=Object.assign({caseSensitive:!1},e),r=t+JSON.stringify(n);if(m.has(r))return m.get(r);var i="!"===t[0];i&&(t=t.slice(1)),t=g(t).replace(/\\\*/g,".*");var o=new RegExp("^".concat(t,"$"),n.caseSensitive?"":"i");return o.negated=i,m.set(r,o),o}(e,n),i=r.test(t);return r.negated?!i:i};function b(t){var e=function(t,e){if("object"!==f()(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==f()(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===f()(e)?e:String(e)}function x(t){return t.filter(function(t,e,n){return e==n.indexOf(t)})}function _(t,e){return"string"==typeof e&&e.match(/[\*\!]/)?t.filter(function(t){return w(t,e)}).length>0:Array.isArray(e)?e.some(function(e){return _(t,e)}):t.includes(e)}function S(t){return t.length>0}function E(t,e){return x([].concat(y()(t),[e]))}function O(t,e){return x(t).filter(function(t){return t!==e})}function j(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;return n>r?L(t,e):i()({},t,d()({},e,{current:n,total:r,percent:100*n/r}))}function L(t,e){t[e];return p()(t,[e].map(b))}function $(t,e){var n=t[e];return n?n.percent:0}var C,k=n(2),A=n.n(k),F=n(5),P=n.n(F),N=n(9),T=n.n(N);function I(t,e){var n={};"object"===f()(t)&&(e=t,t=null);for(var r=Array.isArray(e),i=function(){var e=T()(a[o],2),i=e[0],s=e[1],u=void 0,c=void 0,f=void 0;s===Object(s)?(r?(u=s.action,void 0!==s.method&&(u=s.method)):u=i,c=s.action,f=s.loader):r?(u=c=s,f=s):(u=c=i,f=s),f||(f=c),c&&(n[u]=P()(A.a.mark(function e(){var n,r,i,o,a=arguments;return A.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,this.__$waitInstance.start(f),r=a.length,i=new Array(r),o=0;o2&&void 0!==arguments[2]&&arguments[2];return"function"!=typeof e?(console.warn("[vue-wait] waitFor second argument must be a function"),e):!0===n?function(){try{this.__$waitInstance.start(t);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]?arguments[0]:{};a()(this,t);this.options=i()({},{accessorName:"$wait",useVuex:!1,vuexModuleName:"wait",registerComponent:!0,componentName:"v-wait",registerDirective:!0,directiveName:"wait"},e),this.initialized=!1}return u()(t,[{key:"init",value:function(t,e){if(!this.initialized){if(this.options.registerComponent&&t.component(this.options.componentName,z),this.options.registerDirective&&t.directive(this.options.directiveName,U),this.options.useVuex){var n=this.options.vuexModuleName;if(!e)throw new Error("[vue-wait] Vuex not initialized.");this.store=e,e._modules.get([n])||e.registerModule(n,W),this.stateHandler=new t({computed:{is:function(){return function(t){return e.getters["".concat(n,"/is")](t)}},any:function(){return e.getters["".concat(n,"/any")]},percent:function(){return function(t){return e.getters["".concat(n,"/percent")](t)}}}})}else this.stateHandler=new t({data:function(){return{waitingFor:[],progresses:{}}},computed:{is:function(){var t=this;return function(e){return _(t.waitingFor,e)}},any:function(){return S(this.waitingFor)},percent:function(){var t=this;return function(e){return $(t.progresses,e)}}},methods:{start:function(t){this.waitingFor=E(this.waitingFor,t)},end:function(t){this.waitingFor=O(this.waitingFor,t),this.progresses=L(this.progresses,t)},progress:function(t){var e=t.waiter,n=t.current,r=t.total;this.progresses=j(this.progresses,e,n,r)}}});this.initialized=!0}}},{key:"is",value:function(t){return this.stateHandler.is(t)}},{key:"waiting",value:function(t){return this.is(t)}},{key:"percent",value:function(t){return this.stateHandler.percent(t)}},{key:"dispatchWaitingAction",value:function(t,e){var n=this.options.vuexModuleName;this.store.dispatch("".concat(n,"/").concat(t),e,{root:!0})}},{key:"start",value:function(t){this.options.useVuex?this.dispatchWaitingAction("start",t):this.stateHandler.start(t)}},{key:"end",value:function(t){this.options.useVuex?this.dispatchWaitingAction("end",t):this.stateHandler.end(t)}},{key:"progress",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100;this.is(t)||this.start(t),e>n?this.end(t):this.options.useVuex?this.dispatchWaitingAction("progress",{waiter:t,current:e,total:n}):this.stateHandler.progress({waiter:t,current:e,total:n})}},{key:"any",get:function(){return this.stateHandler.any}}]),t}();function Y(t){Y.installed&&t||(t.mixin({beforeCreate:function(){var e=this.$options,n=e.wait,r=e.store,i=e.parent,o=null;n?(o="function"==typeof n?new n:n).init(t,r):i&&i.__$waitInstance&&(o=i.__$waitInstance).init(t,i.$store),o&&(this.__$waitInstance=o,this[o.options.accessorName]=o)}}),Y.installed=!0)}X.install=Y}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueWait=e():t.VueWait=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=r=function(t){return n(t)}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(e)}t.exports=r},function(t,e,n){t.exports=n(16)},function(t,e,n){var r=n(0);t.exports=function(t){for(var e=1;e=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}},function(t,e,n){var r=n(17),i=n(18),o=n(19);t.exports=function(t,e){return r(t)||i(t,e)||o()}},function(t,e,n){t.exports=n(20)},function(t,e){t.exports=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r=0||(i[n]=t[n]);return i}},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;j(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:$(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var r=n(3),i=n.n(r),o=n(6),a=n.n(o),s=n(7),u=n.n(s),c=n(1),f=n.n(c),l=n(8),p=n.n(l),h=n(0),d=n.n(h),v=n(4),y=n.n(v),g=n(15),m=new Map;var w=function(t,e,n){var r=function(t,e){var n=Object.assign({caseSensitive:!1},e),r=t+JSON.stringify(n);if(m.has(r))return m.get(r);var i="!"===t[0];i&&(t=t.slice(1)),t=g(t).replace(/\\\*/g,".*");var o=new RegExp("^".concat(t,"$"),n.caseSensitive?"":"i");return o.negated=i,m.set(r,o),o}(e,n),i=r.test(t);return r.negated?!i:i};function b(t){var e=function(t,e){if("object"!==f()(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==f()(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===f()(e)?e:String(e)}function x(t){return t.filter(function(t,e,n){return e==n.indexOf(t)})}function _(t,e){return"string"==typeof e&&e.match(/[\*\!]/)?t.filter(function(t){return w(t,e)}).length>0:Array.isArray(e)?e.some(function(e){return _(t,e)}):t.includes(e)}function S(t){return t.length>0}function E(t,e){return x([].concat(y()(t),[e]))}function O(t,e){return x(t).filter(function(t){return t!==e})}function j(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;return n>r?L(t,e):i()({},t,d()({},e,{current:n,total:r,percent:100*n/r}))}function L(t,e){t[e];return p()(t,[e].map(b))}function $(t,e){var n=t[e];return n?n.percent:0}var C,k=n(2),A=n.n(k),F=n(5),P=n.n(F),N=n(9),T=n.n(N);function I(t,e){var n={};"object"===f()(t)&&(e=t,t=null);for(var r=Array.isArray(e),i=function(){var e=T()(a[o],2),i=e[0],s=e[1],u=void 0,c=void 0,f=void 0;s===Object(s)?(r?(u=s.action,void 0!==s.method&&(u=s.method)):u=i,c=s.action,f=s.loader):r?(u=c=s,f=s):(u=c=i,f=s),f||(f=c),c&&(n[u]=P()(A.a.mark(function e(){var n,r,i,o,a=arguments;return A.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,this.__$waitInstance.start(f),r=a.length,i=new Array(r),o=0;o2&&void 0!==arguments[2]&&arguments[2];return"function"!=typeof e?(console.warn("[vue-wait] waitFor second argument must be a function"),e):!0===n?function(){try{this.__$waitInstance.start(t);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]?arguments[0]:{};a()(this,t);this.options=i()({},{accessorName:"$wait",useVuex:!1,vuexModuleName:"wait",registerComponent:!0,componentName:"v-wait",registerDirective:!0,directiveName:"wait"},e),this.initialized=!1}return u()(t,[{key:"init",value:function(t,e){if(!this.initialized){if(this.options.registerComponent&&t.component(this.options.componentName,z),this.options.registerDirective&&t.directive(this.options.directiveName,U),this.options.useVuex){var n=this.options.vuexModuleName;if(!e)throw new Error("[vue-wait] Vuex not initialized.");this.store=e,e._modules.get([n])||e.registerModule(n,W),this.stateHandler=new t({computed:{is:function(){return function(t){return e.getters["".concat(n,"/is")](t)}},any:function(){return e.getters["".concat(n,"/any")]},percent:function(){return function(t){return e.getters["".concat(n,"/percent")](t)}}}})}else this.stateHandler=new t({data:function(){return{waitingFor:[],progresses:{}}},computed:{is:function(){var t=this;return function(e){return _(t.waitingFor,e)}},any:function(){return S(this.waitingFor)},percent:function(){var t=this;return function(e){return $(t.progresses,e)}}},methods:{start:function(t){this.waitingFor=E(this.waitingFor,t)},end:function(t){this.waitingFor=O(this.waitingFor,t),this.progresses=L(this.progresses,t)},progress:function(t){var e=t.waiter,n=t.current,r=t.total;this.progresses=j(this.progresses,e,n,r)}}});this.initialized=!0}}},{key:"is",value:function(t){return this.stateHandler.is(t)}},{key:"waiting",value:function(t){return this.is(t)}},{key:"percent",value:function(t){return this.stateHandler.percent(t)}},{key:"dispatchWaitingAction",value:function(t,e){var n=this.options.vuexModuleName;this.store.dispatch("".concat(n,"/").concat(t),e,{root:!0})}},{key:"start",value:function(t){this.options.useVuex?this.dispatchWaitingAction("start",t):this.stateHandler.start(t)}},{key:"end",value:function(t){this.options.useVuex?this.dispatchWaitingAction("end",t):this.stateHandler.end(t)}},{key:"progress",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100;this.is(t)||this.start(t),e>n?this.end(t):this.options.useVuex?this.dispatchWaitingAction("progress",{waiter:t,current:e,total:n}):this.stateHandler.progress({waiter:t,current:e,total:n})}},{key:"any",get:function(){return this.stateHandler.any}}]),t}();function Y(t){Y.installed&&t||(t.mixin({beforeCreate:function(){var e=this.$options,n=e.wait,r=e.store,i=e.parent,o=null;n?(o="function"==typeof n?new n:n).init(t,r):i&&i.__$waitInstance&&(o=i.__$waitInstance).init(t,i.$store),o&&(this.__$waitInstance=o,this[o.options.accessorName]=o)}}),Y.installed=!0)}X.install=Y}])}); \ No newline at end of file diff --git a/examples/transition-example/main.vue b/examples/transition-example/main.vue index f1ded1c..98aa875 100644 --- a/examples/transition-example/main.vue +++ b/examples/transition-example/main.vue @@ -16,6 +16,7 @@
  • Four
  • Five
  • +
    Second Component
    @@ -33,6 +34,7 @@
  • Four
  • Five
  • +
    Second Component
    diff --git a/src/components/v-wait.vue b/src/components/v-wait.vue index 0450d61..f12a655 100644 --- a/src/components/v-wait.vue +++ b/src/components/v-wait.vue @@ -1,5 +1,6 @@