Skip to content

Commit 6319cee

Browse files
author
Gabriel Schulhof
committed
createDom: Assume structure { tagName: [ {attributes}, [ children ] ] } instead of figuring out whether children is first or attributes is first in the array
1 parent 9396011 commit 6319cee

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

js/jquery.mobile.createDom.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ define( [ "jquery.mobile.core" ], function( $ ) {
1111
// 1. { tagname: [ { attr: value, ... }, [ children ]] }
1212
// 2. "a string"
1313
function mkEl( el ) {
14-
var ret, key, idx, attr, children, child;
14+
var ret, key, attr, children, child;
1515

1616
if ( $.type( el ) === "string" ) {
1717
ret = document.createTextNode( el );
1818
} else {
1919
for ( key in el ) {
2020
ret = document.createElement( key );
21-
for( idx in el[ key ] ) {
22-
if ( $.type( el[ key ][ idx ] ) === "object" ) {
23-
for( attr in el[ key ][ idx ] ) {
24-
ret.setAttribute( attr, el[ key ][ idx ][ attr ] );
25-
}
26-
} else if ( $.type( el[ key ][ idx ] ) === "array" ) {
27-
children = mkChildren( el[ key ][ idx ] );
28-
for( child in children ) {
29-
ret.appendChild( children[ child ] );
30-
}
31-
}
21+
for( attr in el[ key ][ 0 ] ) {
22+
ret.setAttribute( attr, el[ key ][ 0 ][ attr ] );
23+
}
24+
children = mkChildren( el[ key ][ 1 ] );
25+
for( child in children ) {
26+
ret.appendChild( children[ child ] );
3227
}
3328
}
3429
}

0 commit comments

Comments
 (0)