Created
February 25, 2010 18:18
-
-
Save bga/314850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@fn construct HTMLDocumentFragment or HTMLElement from 'html' string in 'doc' | |
@param html string that contains html | |
@param doc owner HTMLDocument for result. Optional | |
@return HTMLDocumentFragment or HTMLElement depend from 'html' | |
*/ | |
$jb.DOMNode._fromHTML=null; | |
if("applyElement" in $h) | |
{ | |
$jb.DOMNode._fromHTML=function(html,doc) | |
{ | |
if(doc==null) | |
doc=$d; | |
var div=doc.createElement("div"); | |
div.innerHTML=html+""; | |
if(div.childNodes.length==1) | |
return div.removeChild(div.firstChild); | |
var df=doc.createDocumentFragment(); | |
var div2=doc.createElement("div"); | |
df.appendChild(div); | |
div2.applyElement(div,"inside"); | |
return df; | |
}; | |
} | |
else | |
{ | |
$jb.DOMNode._fromHTML=function(html,doc) | |
{ | |
if(doc==null) | |
doc=$d; | |
var div=doc.createElement("div"); | |
div.innerHTML=html+""; | |
if(div.childNodes.length==1) | |
return div.removeChild(div.firstChild); | |
var df=doc.createDocumentFragment(); | |
var tmp; | |
while((tmp=div.firstChild)!=null) | |
df.appendChild(tmp); | |
return df; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment