pure-upload
Advanced tools
Comparing version 5.2.0 to 5.3.0
# CHANGELOG | ||
## 5.3.0 | ||
Enable event binding in capturing mode | ||
## 5.2.0 | ||
@@ -4,0 +8,0 @@ |
22
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function addEventHandler(el, event, handler) { | ||
function addEventHandler(el, event, handler, useCapture) { | ||
if (el.addEventListener) { | ||
el.addEventListener(event, handler); | ||
el.addEventListener(event, handler, useCapture); | ||
} | ||
@@ -262,3 +262,4 @@ else { | ||
multiple: true, | ||
allowEmptyFile: false | ||
allowEmptyFile: false, | ||
useCapture: false | ||
}; | ||
@@ -340,3 +341,3 @@ }; | ||
var onChange = function (e) { return _this.onChange(e); }; | ||
addEventHandler(this._fileInput, "change", onChange); | ||
addEventHandler(this._fileInput, "change", onChange, this.options.useCapture); | ||
this.unregisterOnChange = function () { | ||
@@ -356,18 +357,19 @@ if (_this._fileInput) | ||
var onClick = function () { return _this.onClick(); }; | ||
addEventHandler(this.targetElement, "click", onClick); | ||
var useCapture = this.options.useCapture; | ||
addEventHandler(this.targetElement, "click", onClick, useCapture); | ||
this.unregisterOnClick = function () { return removeEventHandler(_this.targetElement, "click", onClick); }; | ||
var onDrag = (function (e) { return _this.onDrag(e); }); | ||
addEventHandler(this.targetElement, "dragover", onDrag); | ||
addEventHandler(this.targetElement, "dragover", onDrag, useCapture); | ||
this.unregisterOnDragOver = function () { return removeEventHandler(_this.targetElement, "dragover", onDrag); }; | ||
var onDragLeave = function () { return _this.onDragLeave(); }; | ||
addEventHandler(this.targetElement, "dragleave", onDragLeave); | ||
addEventHandler(this.targetElement, "dragleave", onDragLeave, useCapture); | ||
this.unregisterOnDragOver = function () { return removeEventHandler(_this.targetElement, "dragleave", onDragLeave); }; | ||
var onDragGlobal = function () { return _this.onDragGlobal(); }; | ||
addEventHandler(document.body, "dragover", onDragGlobal); | ||
addEventHandler(document.body, "dragover", onDragGlobal, useCapture); | ||
this.unregisterOnDragOverGlobal = function () { return removeEventHandler(document.body, "dragover", onDragGlobal); }; | ||
var onDragLeaveGlobal = function () { return _this.onDragLeaveGlobal(); }; | ||
addEventHandler(document.body, "dragleave", onDragLeaveGlobal); | ||
addEventHandler(document.body, "dragleave", onDragLeaveGlobal, useCapture); | ||
this.unregisterOnDragOverGlobal = function () { return removeEventHandler(document.body, "dragleave", onDragLeaveGlobal); }; | ||
var onDrop = (function (e) { return _this.onDrop(e); }); | ||
addEventHandler(this.targetElement, "drop", onDrop); | ||
addEventHandler(this.targetElement, "drop", onDrop, useCapture); | ||
this.unregisterOnDrop = function () { return removeEventHandler(_this.targetElement, "drop", onDrop); }; | ||
@@ -374,0 +376,0 @@ }; |
25
index.ts
export function addEventHandler( | ||
el: Element | HTMLElement, | ||
event: string, | ||
handler: EventListenerOrEventListenerObject | ||
handler: EventListenerOrEventListenerObject, | ||
useCapture: boolean | ||
) { | ||
if (el.addEventListener) { | ||
el.addEventListener(event, handler); | ||
el.addEventListener(event, handler, useCapture); | ||
} else { | ||
@@ -176,2 +177,3 @@ let elem = <IElementWithEvents>el; | ||
validateExtension: boolean; | ||
useCapture: boolean; | ||
@@ -301,2 +303,3 @@ localizer: ILocalizer; | ||
dragOverGlobalStyle?: string; | ||
useCapture?: boolean; | ||
@@ -457,3 +460,4 @@ onFileAdded?: (file: IUploadFile) => void; | ||
multiple: true, | ||
allowEmptyFile: false | ||
allowEmptyFile: false, | ||
useCapture: false | ||
}; | ||
@@ -541,3 +545,3 @@ } | ||
const onChange = (e: Event) => this.onChange(e); | ||
addEventHandler(this._fileInput, "change", onChange); | ||
addEventHandler(this._fileInput, "change", onChange, this.options.useCapture); | ||
this.unregisterOnChange = () => { | ||
@@ -559,23 +563,24 @@ if (this._fileInput) removeEventHandler(this._fileInput, "change", onchange as EventListener); | ||
const onClick = () => this.onClick(); | ||
addEventHandler(this.targetElement, "click", onClick); | ||
let useCapture = this.options.useCapture; | ||
addEventHandler(this.targetElement, "click", onClick, useCapture); | ||
this.unregisterOnClick = () => removeEventHandler(this.targetElement, "click", onClick); | ||
const onDrag = ((e: DragEvent) => this.onDrag(e)) as EventListenerOrEventListenerObject; | ||
addEventHandler(this.targetElement, "dragover", onDrag); | ||
addEventHandler(this.targetElement, "dragover", onDrag, useCapture); | ||
this.unregisterOnDragOver = () => removeEventHandler(this.targetElement, "dragover", onDrag); | ||
const onDragLeave = () => this.onDragLeave(); | ||
addEventHandler(this.targetElement, "dragleave", onDragLeave); | ||
addEventHandler(this.targetElement, "dragleave", onDragLeave, useCapture); | ||
this.unregisterOnDragOver = () => removeEventHandler(this.targetElement, "dragleave", onDragLeave); | ||
const onDragGlobal = () => this.onDragGlobal(); | ||
addEventHandler(document.body, "dragover", onDragGlobal); | ||
addEventHandler(document.body, "dragover", onDragGlobal, useCapture); | ||
this.unregisterOnDragOverGlobal = () => removeEventHandler(document.body, "dragover", onDragGlobal); | ||
const onDragLeaveGlobal = () => this.onDragLeaveGlobal(); | ||
addEventHandler(document.body, "dragleave", onDragLeaveGlobal); | ||
addEventHandler(document.body, "dragleave", onDragLeaveGlobal, useCapture); | ||
this.unregisterOnDragOverGlobal = () => removeEventHandler(document.body, "dragleave", onDragLeaveGlobal); | ||
const onDrop = ((e: DragEvent) => this.onDrop(e)) as EventListenerOrEventListenerObject; | ||
addEventHandler(this.targetElement, "drop", onDrop); | ||
addEventHandler(this.targetElement, "drop", onDrop, useCapture); | ||
this.unregisterOnDrop = () => removeEventHandler(this.targetElement, "drop", onDrop); | ||
@@ -582,0 +587,0 @@ } |
{ | ||
"name": "pure-upload", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"description": "The pure upload library without dependencies", | ||
@@ -5,0 +5,0 @@ "author": { |
declare module "pure-upload" { | ||
export function addEventHandler(el: Element | HTMLElement, event: string, handler: EventListenerOrEventListenerObject): void; | ||
export function addEventHandler(el: Element | HTMLElement, event: string, handler: EventListenerOrEventListenerObject, useCapture: boolean): void; | ||
export const isFileApi: boolean; | ||
@@ -19,2 +19,3 @@ export function castFiles(fileList: File[] | Object, status?: UploadStatus): IUploadFile[]; | ||
validateExtension: boolean; | ||
useCapture: boolean; | ||
localizer: ILocalizer; | ||
@@ -69,2 +70,3 @@ } | ||
dragOverGlobalStyle?: string; | ||
useCapture?: boolean; | ||
onFileAdded?: (file: IUploadFile) => void; | ||
@@ -71,0 +73,0 @@ onFileSelected?: (file: IUploadFile) => void; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87460
2149