1
1
/**
2
- * element-form-builder v1.1 .0
2
+ * element-form-builder v1.2 .0
3
3
* (c) 2019 Felix Yang
4
4
*/
5
5
var _extends = Object . assign || function ( target ) {
@@ -126,6 +126,22 @@ var FormBuilder = {
126
126
127
127
return _extends ( { } , defaultValues , model ) ;
128
128
} ,
129
+ filterAttrs : function filterAttrs ( ) {
130
+ var detail = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
131
+
132
+ var keys = Object . keys ( detail ) ;
133
+ var attrs = { } ;
134
+
135
+ keys . forEach ( function ( key ) {
136
+ var value = detail [ key ] ;
137
+
138
+ if ( typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' ) {
139
+ attrs [ key ] = value ;
140
+ }
141
+ } ) ;
142
+
143
+ return attrs ;
144
+ } ,
129
145
renderFormItem : function renderFormItem ( h , _ref2 ) {
130
146
var tag = _ref2 . tag ,
131
147
_ref2$item = _ref2 . item ,
@@ -149,14 +165,14 @@ var FormBuilder = {
149
165
150
166
if ( tag === 'el-select' ) {
151
167
var select = h ( tag , {
152
- attrs : _extends ( { } , detail ) ,
168
+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
153
169
props : _extends ( {
154
170
value : value
155
171
} , detail ) ,
156
172
on : _extends ( { } , modelEvents )
157
173
} , ( detail . items || [ ] ) . map ( function ( option ) {
158
174
return h ( 'el-option' , {
159
- attrs : _extends ( { } , option ) ,
175
+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
160
176
props : _extends ( {
161
177
key : option . value
162
178
} , option )
@@ -165,14 +181,14 @@ var FormBuilder = {
165
181
children = [ select ] ;
166
182
} else if ( tag === 'el-checkbox' ) {
167
183
var checkbox = h ( 'el-checkbox-group' , {
168
- attrs : _extends ( { } , detail ) ,
184
+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
169
185
props : _extends ( {
170
186
value : value
171
187
} , detail ) ,
172
188
on : _extends ( { } , modelEvents )
173
189
} , ( detail . items || [ ] ) . map ( function ( option ) {
174
190
return h ( 'el-checkbox' , {
175
- attrs : _extends ( { } , option ) ,
191
+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
176
192
props : _extends ( {
177
193
key : option . value ,
178
194
label : option . value
@@ -187,7 +203,7 @@ var FormBuilder = {
187
203
name : detail . name
188
204
} , option ) ;
189
205
return h ( tag , {
190
- attrs : _extends ( { } , option ) ,
206
+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
191
207
props : _extends ( {
192
208
value : value
193
209
} , option ) ,
@@ -197,7 +213,7 @@ var FormBuilder = {
197
213
children = [ ] . concat ( toConsumableArray ( radios ) ) ;
198
214
} else {
199
215
var input = h ( tag || 'el-input' , {
200
- attrs : _extends ( { } , detail ) ,
216
+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
201
217
props : _extends ( {
202
218
value : value
203
219
} , detail ) ,
0 commit comments