11/**
2- * element-form-builder v1.1 .0
2+ * element-form-builder v1.2 .0
33 * (c) 2019 Felix Yang
44 */
55var _extends = Object . assign || function ( target ) {
@@ -126,6 +126,22 @@ var FormBuilder = {
126126
127127 return _extends ( { } , defaultValues , model ) ;
128128 } ,
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+ } ,
129145 renderFormItem : function renderFormItem ( h , _ref2 ) {
130146 var tag = _ref2 . tag ,
131147 _ref2$item = _ref2 . item ,
@@ -149,14 +165,14 @@ var FormBuilder = {
149165
150166 if ( tag === 'el-select' ) {
151167 var select = h ( tag , {
152- attrs : _extends ( { } , detail ) ,
168+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
153169 props : _extends ( {
154170 value : value
155171 } , detail ) ,
156172 on : _extends ( { } , modelEvents )
157173 } , ( detail . items || [ ] ) . map ( function ( option ) {
158174 return h ( 'el-option' , {
159- attrs : _extends ( { } , option ) ,
175+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
160176 props : _extends ( {
161177 key : option . value
162178 } , option )
@@ -165,14 +181,14 @@ var FormBuilder = {
165181 children = [ select ] ;
166182 } else if ( tag === 'el-checkbox' ) {
167183 var checkbox = h ( 'el-checkbox-group' , {
168- attrs : _extends ( { } , detail ) ,
184+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
169185 props : _extends ( {
170186 value : value
171187 } , detail ) ,
172188 on : _extends ( { } , modelEvents )
173189 } , ( detail . items || [ ] ) . map ( function ( option ) {
174190 return h ( 'el-checkbox' , {
175- attrs : _extends ( { } , option ) ,
191+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
176192 props : _extends ( {
177193 key : option . value ,
178194 label : option . value
@@ -187,7 +203,7 @@ var FormBuilder = {
187203 name : detail . name
188204 } , option ) ;
189205 return h ( tag , {
190- attrs : _extends ( { } , option ) ,
206+ attrs : _extends ( { } , vm . filterAttrs ( option ) ) ,
191207 props : _extends ( {
192208 value : value
193209 } , option ) ,
@@ -197,7 +213,7 @@ var FormBuilder = {
197213 children = [ ] . concat ( toConsumableArray ( radios ) ) ;
198214 } else {
199215 var input = h ( tag || 'el-input' , {
200- attrs : _extends ( { } , detail ) ,
216+ attrs : _extends ( { } , vm . filterAttrs ( detail ) ) ,
201217 props : _extends ( {
202218 value : value
203219 } , detail ) ,
0 commit comments