mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-04 06:43:15 +02:00
parent
b080bcda7d
commit
2e004015d5
|
@ -1871,6 +1871,7 @@ class Choices {
|
|||
element: this._getTemplate('input', this._placeholderValue),
|
||||
classNames: this.config.classNames,
|
||||
type: this.passedElement.element.type,
|
||||
preventPaste: !this.config.paste,
|
||||
});
|
||||
|
||||
this.choiceList = new List({
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
import { sanitise } from '../lib/utils';
|
||||
|
||||
export default class Input {
|
||||
constructor({ element, type, classNames, placeholderValue }) {
|
||||
Object.assign(this, { element, type, classNames, placeholderValue });
|
||||
/**
|
||||
*
|
||||
* @typedef {import('../../../types/index').Choices.passedElement} passedElement
|
||||
* @typedef {import('../../../types/index').Choices.ClassNames} ClassNames
|
||||
* @param {{element: HTMLInputElement, type: passedElement['type'], classNames: ClassNames, preventPaste: boolean }} p
|
||||
*/
|
||||
constructor({ element, type, classNames, preventPaste }) {
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
this.classNames = classNames;
|
||||
this.preventPaste = preventPaste;
|
||||
|
||||
this.isFocussed = this.element === document.activeElement;
|
||||
this.isDisabled = false;
|
||||
this.isDisabled = element.disabled;
|
||||
this._onPaste = this._onPaste.bind(this);
|
||||
this._onInput = this._onInput.bind(this);
|
||||
this._onFocus = this._onFocus.bind(this);
|
||||
|
@ -112,8 +120,7 @@ export default class Input {
|
|||
}
|
||||
|
||||
_onPaste(event) {
|
||||
const { target } = event;
|
||||
if (target === this.element && this.preventPaste) {
|
||||
if (this.preventPaste) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue