From d3944e7c843eec5794fce93c77399c091df96c79 Mon Sep 17 00:00:00 2001 From: Rik Schennink Date: Fri, 19 Jul 2019 08:14:39 +0200 Subject: [PATCH] fix issue with 'input' event --- CHANGELOG.md | 5 +++++ dist/vue-filepond.esm.js | 8 ++------ dist/vue-filepond.js | 8 ++------ dist/vue-filepond.min.js | 4 ++-- package.json | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9b11c..dff391e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 5.1.2 + +- Fix issue with 'input' event. + + ## 5.1.1 - Add `detached` method, the component now waits to be removed from the DOM, it then destroys the FilePond instance (the `destroyed` and `beforeDestroy` methods both run while the component is still in the DOM when using transitions). diff --git a/dist/vue-filepond.esm.js b/dist/vue-filepond.esm.js index 7be8910..4c7ad1d 100644 --- a/dist/vue-filepond.esm.js +++ b/dist/vue-filepond.esm.js @@ -1,5 +1,5 @@ /*! - * vue-filepond v5.1.1 + * vue-filepond v5.1.2 * A handy FilePond adapter component for Vue * * Copyright (c) 2019 PQINA @@ -135,11 +135,7 @@ export default (...plugins) => { // Map FilePond callback methods to Vue $emitters const options = events.reduce((obj, value) => { obj[value] = (...args) => { - if(this._pond){ - this.$emit('input', this._pond.getFiles()); - }else{ - this.$emit('input', []); - } + this.$emit('input', this._pond ? this._pond.getFiles() : []); this.$emit(value.substr(2), ...args); }; return obj; diff --git a/dist/vue-filepond.js b/dist/vue-filepond.js index 6121c50..1d606ee 100644 --- a/dist/vue-filepond.js +++ b/dist/vue-filepond.js @@ -1,5 +1,5 @@ /*! - * vue-filepond v5.1.1 + * vue-filepond v5.1.2 * A handy FilePond adapter component for Vue * * Copyright (c) 2019 PQINA @@ -150,11 +150,7 @@ args[_key] = arguments[_key]; } - if (_this._pond) { - _this.$emit('input', _this._pond.getFiles()); - } else { - _this.$emit('input', []); - } + _this.$emit('input', _this._pond ? _this._pond.getFiles() : []); _this.$emit.apply(_this, [value.substr(2)].concat(args)); }; return obj; diff --git a/dist/vue-filepond.min.js b/dist/vue-filepond.min.js index c593989..28068ca 100644 --- a/dist/vue-filepond.min.js +++ b/dist/vue-filepond.min.js @@ -1,5 +1,5 @@ /*! - * vue-filepond v5.1.1 + * vue-filepond v5.1.2 * A handy FilePond adapter component for Vue * * Copyright (c) 2019 PQINA @@ -7,4 +7,4 @@ * * Licensed under the MIT license. */ -!function(global,factory){if("function"==typeof define&&define.amd)define("vueFilePond",["exports","vue","filepond"],factory);else if("undefined"!=typeof exports)factory(exports,require("vue"),require("filepond"));else{var mod_exports={};factory(mod_exports,global.Vue,global.FilePond),global.vueFilePond=mod_exports}}(this,function(exports,_vue,_filepond){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setOptions=void 0;var obj,_vue2=(obj=_vue)&&obj.__esModule?obj:{default:obj};var filteredComponentMethods=["setOptions","on","off","onOnce","appendTo","insertAfter","insertBefore","isAttachedTo","replaceElement","restoreElement","destroy"],isSupported=(0,_filepond.supported)(),props={},events=[],watch={},instances=[],globalOptions={};exports.setOptions=function(options){globalOptions=Object.assign(globalOptions,options),instances.forEach(function(instance){instance.setOptions(globalOptions)})};exports.default=function(){_filepond.registerPlugin.apply(void 0,arguments),events.length=0;var _loop=function(prop){if(/^on/.test(prop))return events.push(prop),"continue";props[prop]=[String,function(type){return{string:String,boolean:Boolean,array:Array,function:Function,int:Number,serverapi:Object,object:Object}[type]}(_filepond.OptionTypes[prop])],watch[prop]=function(value){this._pond[prop]=value}};for(var prop in _filepond.OptionTypes)_loop(prop);return _vue2.default.component("FilePond",{name:"FilePond",props:props,watch:watch,render:function(h){return h("div",{class:{"filepond--wrapper":!0}},[h("input",{attrs:{id:this.id,name:this.name,type:"file",class:this.className,required:this.required,multiple:this.allowMultiple,accept:this.acceptedFileTypes,capture:this.captureMethod}})])},mounted:function(){var _this=this;if(isSupported){this._element=this.$el.querySelector("input");var options=events.reduce(function(obj,value){return obj[value]=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];_this._pond?_this.$emit("input",_this._pond.getFiles()):_this.$emit("input",[]),_this.$emit.apply(_this,[value.substr(2)].concat(args))},obj},{}),attrs=Object.assign({},this.$attrs);this._pond=(0,_filepond.create)(this._element,Object.assign({},globalOptions,options,attrs,this.$options.propsData)),Object.keys(this._pond).filter(function(key){return!filteredComponentMethods.includes(key)}).forEach(function(key){_this[key]=_this._pond[key]}),instances.push(this._pond)}},destroyed:function(){var _this2=this,detached=this.$options.detached;if(this.$el.offsetParent){new MutationObserver(function(mutations,observer){!((mutations[0]||{}).removedNodes||[])[0]!==_this2.$el&&(observer.disconnect(),detached.call(_this2))}).observe(this.$parent.$el,{childList:!0})}else detached.call(this)},detached:function(){if(this._pond){this._pond.destroy();var index=instances.indexOf(this._pond);0<=index&&instances.splice(index,1),this._pond=null}}})}}); \ No newline at end of file +!function(global,factory){if("function"==typeof define&&define.amd)define("vueFilePond",["exports","vue","filepond"],factory);else if("undefined"!=typeof exports)factory(exports,require("vue"),require("filepond"));else{var mod_exports={};factory(mod_exports,global.Vue,global.FilePond),global.vueFilePond=mod_exports}}(this,function(exports,_vue,_filepond){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setOptions=void 0;var obj,_vue2=(obj=_vue)&&obj.__esModule?obj:{default:obj};var filteredComponentMethods=["setOptions","on","off","onOnce","appendTo","insertAfter","insertBefore","isAttachedTo","replaceElement","restoreElement","destroy"],isSupported=(0,_filepond.supported)(),props={},events=[],watch={},instances=[],globalOptions={};exports.setOptions=function(options){globalOptions=Object.assign(globalOptions,options),instances.forEach(function(instance){instance.setOptions(globalOptions)})};exports.default=function(){_filepond.registerPlugin.apply(void 0,arguments),events.length=0;var _loop=function(prop){if(/^on/.test(prop))return events.push(prop),"continue";var type;props[prop]=[String,(type=_filepond.OptionTypes[prop],{string:String,boolean:Boolean,array:Array,function:Function,int:Number,serverapi:Object,object:Object}[type])],watch[prop]=function(value){this._pond[prop]=value}};for(var prop in _filepond.OptionTypes)_loop(prop);return _vue2.default.component("FilePond",{name:"FilePond",props:props,watch:watch,render:function(h){return h("div",{class:{"filepond--wrapper":!0}},[h("input",{attrs:{id:this.id,name:this.name,type:"file",class:this.className,required:this.required,multiple:this.allowMultiple,accept:this.acceptedFileTypes,capture:this.captureMethod}})])},mounted:function(){var _this=this;if(isSupported){this._element=this.$el.querySelector("input");var options=events.reduce(function(obj,value){return obj[value]=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];_this.$emit("input",_this._pond?_this._pond.getFiles():[]),_this.$emit.apply(_this,[value.substr(2)].concat(args))},obj},{}),attrs=Object.assign({},this.$attrs);this._pond=(0,_filepond.create)(this._element,Object.assign({},globalOptions,options,attrs,this.$options.propsData)),Object.keys(this._pond).filter(function(key){return!filteredComponentMethods.includes(key)}).forEach(function(key){_this[key]=_this._pond[key]}),instances.push(this._pond)}},destroyed:function(){var _this2=this,detached=this.$options.detached;if(this.$el.offsetParent){new MutationObserver(function(mutations,observer){!((mutations[0]||{}).removedNodes||[])[0]!==_this2.$el&&(observer.disconnect(),detached.call(_this2))}).observe(this.$parent.$el,{childList:!0})}else detached.call(this)},detached:function(){if(this._pond){this._pond.destroy();var index=instances.indexOf(this._pond);0<=index&&instances.splice(index,1),this._pond=null}}})}}); \ No newline at end of file diff --git a/package.json b/package.json index df262b8..48f87cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-filepond", - "version": "5.1.1", + "version": "5.1.2", "description": "A handy FilePond adapter component for Vue", "homepage": "https://pqina.nl/filepond", "license": "MIT",