Added readonly attr support
This commit is contained in:
parent
5f257a6e78
commit
c1c0cf36d0
17
components/dist/select.js
vendored
17
components/dist/select.js
vendored
@ -16,6 +16,10 @@ smSelect.innerHTML = `
|
|||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
:host([readonly]) .select{
|
||||||
|
cursor: default;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
.select{
|
.select{
|
||||||
position: relative;
|
position: relative;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
@ -175,7 +179,7 @@ customElements.define('sm-select', class extends HTMLElement {
|
|||||||
this.selectedOptionText = this.shadowRoot.querySelector('.selected-option-text')
|
this.selectedOptionText = this.shadowRoot.querySelector('.selected-option-text')
|
||||||
}
|
}
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
return ['disabled', 'label']
|
return ['disabled', 'label', 'readonly']
|
||||||
}
|
}
|
||||||
get value() {
|
get value() {
|
||||||
return this.getAttribute('value')
|
return this.getAttribute('value')
|
||||||
@ -364,20 +368,21 @@ customElements.define('sm-select', class extends HTMLElement {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).observe(this)
|
}).observe(this)
|
||||||
this.addEventListener('click', this.handleClick)
|
|
||||||
this.addEventListener('keydown', this.handleKeydown)
|
|
||||||
}
|
}
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
this.removeEventListener('click', this.handleClick)
|
this.removeEventListener('click', this.handleClick)
|
||||||
this.removeEventListener('click', this.toggle)
|
|
||||||
this.removeEventListener('keydown', this.handleKeydown)
|
this.removeEventListener('keydown', this.handleKeydown)
|
||||||
}
|
}
|
||||||
attributeChangedCallback(name) {
|
attributeChangedCallback(name) {
|
||||||
if (name === "disabled") {
|
if (name === "disabled" || name === "readonly") {
|
||||||
if (this.hasAttribute('disabled')) {
|
if (this.hasAttribute('disabled') || this.hasAttribute('readonly')) {
|
||||||
this.selection.removeAttribute('tabindex')
|
this.selection.removeAttribute('tabindex')
|
||||||
|
this.removeEventListener('click', this.handleClick)
|
||||||
|
this.removeEventListener('keydown', this.handleKeydown)
|
||||||
} else {
|
} else {
|
||||||
this.selection.setAttribute('tabindex', '0')
|
this.selection.setAttribute('tabindex', '0')
|
||||||
|
this.addEventListener('click', this.handleClick)
|
||||||
|
this.addEventListener('keydown', this.handleKeydown)
|
||||||
}
|
}
|
||||||
} else if (name === 'label') {
|
} else if (name === 'label') {
|
||||||
this.label = this.hasAttribute('label') ? `${this.getAttribute('label')} ` : ''
|
this.label = this.hasAttribute('label') ? `${this.getAttribute('label')} ` : ''
|
||||||
|
|||||||
2
components/dist/select.min.js
vendored
2
components/dist/select.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user