Skip to content

Commit 84b5672

Browse files
author
Gabriel Schulhof
committed
createDom: renaming to makeDom and using the solution proposed by arschmitz
1 parent c6c86a5 commit 84b5672

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

js/jquery.mobile.createDom.js

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,15 @@ define( [ "jquery.mobile.core" ], function( $ ) {
77
//>>excludeEnd("jqmBuildExclude");
88
(function( $, undefined ) {
99

10-
//el can be one of two things:
11-
// 1. [ tagname, { attr: value, ... }, [ children ] ]
12-
// 2. "a string"
13-
var mkEl = function( el ) {
14-
var ret, key, attr, children, child;
15-
16-
if ( $.type( el ) === "string" ) {
17-
ret = document.createTextNode( el );
18-
} else {
19-
ret = document.createElement( el[ 0 ] );
20-
for( attr in el[ 1 ] ) {
21-
ret.setAttribute( attr, el[ 1 ][ attr ] );
22-
}
23-
children = mkChildren( el[ 2 ] );
24-
for( child in children ) {
25-
ret.appendChild( children[ child ] );
26-
}
27-
}
28-
29-
return ret;
30-
},
31-
32-
mkChildren = function( c ) {
33-
var ret = [], idx;
34-
35-
for ( idx in c ) {
36-
ret.push( mkEl( c[ idx ] ) );
37-
}
38-
39-
return ret;
40-
};
41-
42-
$.mobile.createDom = mkEl;
43-
$.mobile.createDomElements = mkChildren;
10+
$.mobile.makeDom = function( o ) {
11+
var prop,
12+
ele = document.createElement( o[ 0 ] );
13+
for ( prop in o[ 1 ] ) {
14+
ele.setAttribute( prop, o[ 1 ][ prop ] );
15+
}
16+
ele.innerHTML = o[ 2 ];
17+
return ele;
18+
};
4419

4520
})( jQuery );
4621
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);

0 commit comments

Comments
 (0)