File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -21,19 +21,20 @@ var Element = function(tag, props){
21
21
22
22
if ( ! props ) props = { } ;
23
23
24
- var parsed = Slick . parse ( tag ) . expressions [ 0 ] [ 0 ] ;
25
- tag = parsed . tag || 'div' ;
26
- if ( parsed . id ) props . id = parsed . id ;
27
-
28
- var classes = [ ] ;
29
- parsed . parts . each ( function ( part ) {
30
- switch ( part . type ) {
31
- case 'class' : classes . push ( part . value ) ; break ;
32
- case 'attribute' : if ( part . value && part . operator == '=' ) props [ part . key ] = part . value ;
24
+ if ( ! tag . test ( / ^ \w + $ / ) ) {
25
+ var parsed = Slick . parse ( tag ) . expressions [ 0 ] [ 0 ] ;
26
+ tag = ( parsed . tag == '*' ) ? 'div' : parsed . tag ;
27
+ if ( parsed . id && props . id == null ) props . id = parsed . id ;
28
+
29
+ for ( var i = 0 , l = parsed . parts . length ; i < l ; i ++ ) {
30
+ var part = parsed . parts [ i ] ;
31
+ if ( part . type == 'attribute' && part . value && part . operator == '=' && props [ part . key ] == null )
32
+ props [ part . key ] = part . value ;
33
33
}
34
- } ) ;
35
-
36
- if ( classes . length ) props [ 'class' ] = classes . join ( ' ' ) ;
34
+
35
+ var classList = props [ 'class' ] ;
36
+ if ( parsed . classes ) props [ 'class' ] = ( classList ? classList + ' ' : '' ) + parsed . classes . join ( ' ' ) ;
37
+ }
37
38
38
39
return document . newElement ( tag , props ) ;
39
40
} ;
You can’t perform that action at this time.
0 commit comments