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 {
121
121
elem . checked = true ;
122
122
}
123
123
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 ) => {
131
126
// eslint-disable-next-line no-param-reassign
132
- elem . value = ` ${ value } ` ;
133
- }
127
+ option . selected = this . constructor . $selected ( option . value , value ) ;
128
+ } ) ;
134
129
break ;
135
130
default :
136
131
// eslint-disable-next-line no-param-reassign
@@ -167,15 +162,11 @@ export default class Form extends View {
167
162
values [ key ] = elem . value ;
168
163
}
169
164
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
+ } ) ;
179
170
break ;
180
171
default :
181
172
values [ key ] = elem . value ;
Original file line number Diff line number Diff line change @@ -147,8 +147,12 @@ export default class Provider extends Emitter {
147
147
$fetch ( url , req ) {
148
148
let status ;
149
149
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 )
152
156
. then ( ( response ) => {
153
157
status = response ;
154
158
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) {
44
44
const hasPrefix = this . indexOf ( prefix ) === 0 ;
45
45
return hasPrefix ? this . substr ( prefix . length ) : this . toString ( ) ;
46
46
} ;
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