Arrayify querySelectorAll() results

This commit is contained in:
An Phan 2017-01-18 09:27:03 +08:00
parent e9645bb408
commit 94a54bd182
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2
4 changed files with 9 additions and 11 deletions

View file

@ -126,18 +126,16 @@ export default {
* Update the current user's profile.
*/
update () {
const passwordFields = Array.from(
document.querySelectorAll('#inputProfilePassword, #inputProfileConfirmPassword')
)
// A little validation put in a small place.
if ((this.pwd || this.confirmPwd) && this.pwd !== this.confirmPwd) {
each(
document.querySelectorAll('#inputProfilePassword, #inputProfileConfirmPassword'),
el => $.addClass(el, 'error')
)
each(passwordFields, el => $.addClass(el, 'error'))
return
}
each(document.querySelectorAll('#inputProfilePassword, #inputProfileConfirmPassword'), el => {
$.removeClass(el, 'error')
})
each(passwordFields, el => $.removeClass(el, 'error'))
userStore.updateProfile(this.pwd).then(() => {
this.pwd = ''

View file

@ -149,7 +149,7 @@ export default {
* they don't appear off-screen.
*/
mounted () {
each(this.$el.querySelectorAll('.has-sub'), item => {
each(Array.from(this.$el.querySelectorAll('.has-sub')), item => {
const submenu = item.querySelector('.submenu')
if (!submenu) {
return

View file

@ -135,7 +135,7 @@ export default {
*/
createSliders () {
const config = equalizerStore.get()
each(document.querySelectorAll('#equalizer .slider'), (el, i) => {
each(Array.from(document.querySelectorAll('#equalizer .slider')), (el, i) => {
nouislider.create(el, {
connect: [false, true],
// the first element is the preamp. The rest are gains.
@ -192,7 +192,7 @@ export default {
* Load a preset when the user select it from the dropdown.
*/
loadPreset (preset) {
each(document.querySelectorAll('#equalizer .slider'), (el, i) => {
each(Array.from(document.querySelectorAll('#equalizer .slider')), (el, i) => {
// We treat our preamp slider differently.
if ($.is(el.parentNode, '.preamp')) {
this.changePreampGain(preset.preamp)

View file

@ -24,7 +24,7 @@ export default {
* Close all submenus.
*/
close () {
each(this.$el.querySelectorAll('.submenu'), el => {
each(Array.from(this.$el.querySelectorAll('.submenu')), el => {
el.style.display = 'none'
})
this.shown = false