remove maintain attrs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-16 01:12:07 -04:00
parent c5f96a9d9d
commit fcfd9857d5
19 changed files with 103 additions and 134 deletions

View File

@ -28,14 +28,13 @@ import { LiveSocket } from 'phoenix_live_view'
import topbar from 'topbar'
import Date from './date'
import DateTime from './datetime'
import MaintainAttrs from './maintain_attrs'
const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
let csrfToken
if (csrfTokenElement) { csrfToken = csrfTokenElement.getAttribute('content') }
const liveSocket = new LiveSocket('/live', Socket, {
params: { _csrf_token: csrfToken },
hooks: { Date, DateTime, MaintainAttrs }
hooks: { Date, DateTime }
})
// Show progress bar on live navigation and form submits

View File

@ -1,22 +0,0 @@
// maintain user adjusted attributes, like textbox length on phoenix liveview
// update. https://github.com/phoenixframework/phoenix_live_view/issues/1011
export default {
attrs () {
if (this.el && this.el.getAttribute('data-attrs')) {
return this.el.getAttribute('data-attrs').split(', ')
} else {
return []
}
},
beforeUpdate () {
if (this.el) {
this.prevAttrs = this.attrs().map(name => [name, this.el.getAttribute(name)])
}
},
updated () {
if (this.el) {
this.prevAttrs.forEach(([name, val]) => this.el.setAttribute(name, val))
}
}
}