@@ -1912,52 +1912,9 @@ var TigerJS = function () {
1912
1912
*/
1913
1913
1914
1914
this . create = function ( content ) {
1915
- var re_match = [ ] ,
1916
- //this regexp also takes care of cases where the tag is broken with a new line or feed
1917
- re = new RegExp ( "<([a-z]+\s*)?\s*.*?\s*>\n*\t*\f*\r*(.*?)<\s*/\s*[a-z]*>\*\n*\t*\f*\r*" , "gim" ) ,
1918
- re_empty = new RegExp ( "<([img | hr | br | meta | link | embed]+\s*)?([.])+/>" , "gi" ) , //match empty tags, must be xhtml/xml//
1919
- re_empty_match = [ ] ,
1920
- temp_div , html = "" ,
1921
- tag = tag || "div" ,
1922
- i ;
1923
- content = content . trim ( ) ;
1924
- do {
1925
- ///match empty tags
1926
- re_empty_match [ re_empty_match . length ] = re_empty . exec ( content ) ;
1927
- } while ( re_empty_match [ re_empty_match . length - 1 ] ) ;
1928
- //strip out empty tags
1929
- content = content . replace ( re_empty , "" ) ;
1930
- do { ///match regular tags
1931
- re_match [ re_match . length ] = re . exec ( content ) ; //
1932
-
1933
- } while ( re_match [ re_match . length - 1 ] ) ;
1934
-
1935
- //am creating an Iterator and compacting it cause' during the process some array indices got null or undefined
1936
- //or just magically dissapeared
1937
- //TODO, whats causing this
1938
- re_match = T . Iterator ( re_match . concat ( re_empty_match ) ) .
1939
- compact ( ) ; //addup all the results and create the node
1940
-
1941
-
1942
- //first we use a div as a place holder for all matched elements
1943
- temp_div = document . createElement ( tag ) ;
1944
- for ( i = 0 ; i < re_match . length ; i ++ ) {
1945
- temp_div . innerHTML += re_match [ i ] [ 0 ] ;
1946
-
1947
- }
1948
-
1949
- html = document . createDocumentFragment ( ) ; //fragment to hold All nodes to be appended
1950
-
1951
- for ( i = 0 ; i < temp_div . childNodes . length ; i ++ ) {
1952
- //without cloning nodes here error occurs while appending paragraph element, not sure Y!, ok it seems its
1953
- //some standard DOMException, or heirachy issue, well we have a solution
1954
-
1955
- html . appendChild ( temp_div . childNodes . item ( i ) . cloneNode ( true ) ) ;
1956
- }
1957
-
1958
-
1959
- temp_div = null ;
1960
- return html ; //return the created nodes
1915
+
1916
+ return document . createRange ( ) . createContextualFragment ? //return the created nodes
1917
+ document . createRange ( ) . createContextualFragment ( content ) : ( new DOMParser ( ) ) . parseFromString ( content , 'text/html' ) . body . firstChild ; //return the created nodes
1961
1918
1962
1919
1963
1920
} ;
0 commit comments