File tree Expand file tree Collapse file tree 5 files changed +395
-467
lines changed Expand file tree Collapse file tree 5 files changed +395
-467
lines changed Original file line number Diff line number Diff line change @@ -121,16 +121,11 @@ export default class Form extends View {
121121 elem . checked = true ;
122122 }
123123 break ;
124- case 'select' :
125- if ( elem . multiple ) {
126- elem . options . forEach ( ( opt ) => {
127- // eslint-disable-next-line no-param-reassign
128- opt . selected = this . constructor . $selected ( opt . value , value ) ;
129- } ) ;
130- } else {
124+ case 'select-multiple' :
125+ Array . from ( elem . options ) . forEach ( ( option ) => {
131126 // eslint-disable-next-line no-param-reassign
132- elem . value = ` ${ value } ` ;
133- }
127+ option . selected = this . constructor . $selected ( option . value , value ) ;
128+ } ) ;
134129 break ;
135130 default :
136131 // eslint-disable-next-line no-param-reassign
@@ -167,15 +162,11 @@ export default class Form extends View {
167162 values [ key ] = elem . value ;
168163 }
169164 break ;
170- case 'select' :
171- if ( elem . multiple ) {
172- values [ key ] = [ ] ;
173- elem . selectedOptions . forEach ( ( opt ) => {
174- values [ key ] . push ( opt . value ) ;
175- } ) ;
176- } else {
177- values [ key ] = elem . value ;
178- }
165+ case 'select-multiple' :
166+ values [ key ] = [ ] ;
167+ Array . from ( elem . selectedOptions ) . forEach ( ( option ) => {
168+ values [ key ] . push ( option . value ) ;
169+ } ) ;
179170 break ;
180171 default :
181172 values [ key ] = elem . value ;
Original file line number Diff line number Diff line change @@ -147,8 +147,12 @@ export default class Provider extends Emitter {
147147 $fetch ( url , req ) {
148148 let status ;
149149 let changed = false ;
150- this . dispatchEvent ( EVENT_STARTED , this , this . $origin + ( url || '' ) ) ;
151- fetch ( this . $origin + url , req )
150+ let absurl = this . $origin + ( url || '' ) ;
151+ if ( ! absurl . hasPrefix ( '/' ) ) {
152+ absurl = `/${ absurl } ` ;
153+ }
154+ this . dispatchEvent ( EVENT_STARTED , this , absurl ) ;
155+ fetch ( absurl , req )
152156 . then ( ( response ) => {
153157 status = response ;
154158 const contentType = response . headers ? response . headers . get ( 'Content-Type' ) || '' : '' ;
Original file line number Diff line number Diff line change @@ -44,3 +44,15 @@ String.prototype.removePrefix = function (prefix) {
4444 const hasPrefix = this . indexOf ( prefix ) === 0 ;
4545 return hasPrefix ? this . substr ( prefix . length ) : this . toString ( ) ;
4646} ;
47+
48+ /**
49+ * @function hasPrefix
50+ * @memberof String
51+ * @description Check for prefix on a string.
52+ * @arg {string} prefix - The prefix to test for and remove
53+ * @returns boolean
54+ */
55+ String . prototype . hasPrefix = function ( prefix ) {
56+ const hasPrefix = this . indexOf ( prefix ) === 0 ;
57+ return hasPrefix ;
58+ } ;
You can’t perform that action at this time.
0 commit comments