This commit is contained in:
sairaj mote 2023-04-29 01:10:55 +05:30
parent 48c877c913
commit 44ec803aa0
2 changed files with 51 additions and 43 deletions

View File

@ -534,48 +534,56 @@ customElements.define('sm-input',
this.input.removeAttribute(name); this.input.removeAttribute(name);
} }
} }
if (name === 'placeholder') { switch (name) {
this.label.textContent = newValue; case 'placeholder':
this.setAttribute('aria-label', newValue); this.label.textContent = newValue;
} else if (this.hasAttribute('value')) { this.setAttribute('aria-label', newValue);
this.checkInput(); break;
} else if (name === 'type') { case 'value':
if (this.hasAttribute('type') && this.getAttribute('type') === 'number') { this.checkInput();
this.input.setAttribute('inputmode', 'decimal'); break;
this.input.addEventListener('keydown', this.allowOnlyNum); case 'type':
} else { if (this.hasAttribute('type') && this.getAttribute('type') === 'number') {
this.input.removeEventListener('keydown', this.allowOnlyNum); this.input.setAttribute('inputmode', 'decimal');
this.input.addEventListener('keydown', this.allowOnlyNum);
} } else {
} else if (name === 'helper-text') { this.input.removeEventListener('keydown', this.allowOnlyNum);
this._helperText = this.getAttribute('helper-text'); }
} else if (name === 'error-text') { break;
this._errorText = this.getAttribute('error-text'); case 'helper-text':
} else if (name === 'required') { this._helperText = newValue;
this.isRequired = this.hasAttribute('required'); break;
if (this.isRequired) { case 'error-text':
this.setAttribute('aria-required', 'true'); this._errorText = newValue;
} break;
else { case 'required':
this.setAttribute('aria-required', 'false'); this.isRequired = this.hasAttribute('required');
} if (this.isRequired) {
} else if (name === 'readonly') { this.setAttribute('aria-required', 'true');
if (this.hasAttribute('readonly')) { } else {
this.inputParent.classList.add('readonly'); this.setAttribute('aria-required', 'false');
} else { }
this.inputParent.classList.remove('readonly'); break;
} case 'readonly':
} else if (name === 'disabled') { if (this.hasAttribute('readonly')) {
if (this.hasAttribute('disabled')) { this.inputParent.classList.add('readonly');
this.inputParent.classList.add('disabled'); } else {
} this.inputParent.classList.remove('readonly');
else { }
this.inputParent.classList.remove('disabled'); break;
} case 'disabled':
} else if (name === 'list') { if (this.hasAttribute('disabled')) {
if (this.hasAttribute('list') && this.getAttribute('list').trim() !== '') { this.inputParent.classList.add('disabled');
this.datalist = this.getAttribute('list').split(','); }
} else {
this.inputParent.classList.remove('disabled');
}
break;
case 'list':
if (this.hasAttribute('list') && this.getAttribute('list').trim() !== '') {
this.datalist = this.getAttribute('list').split(',');
}
break;
} }
} }
} }

File diff suppressed because one or more lines are too long