Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/lib/DOM.js
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | if (__DEV__) { | ||||
var wont_work = /<object\b/; | var wont_work = /<object\b/; | ||||
if (str.match(wont_work)) { | if (str.match(wont_work)) { | ||||
JX.$E( | JX.$E( | ||||
'new JX.HTML("...<object>..."): ' + | 'new JX.HTML("...<object>..."): ' + | ||||
'call initializes an HTML object with an embedded <object> tag. IE ' + | 'call initializes an HTML object with an embedded <object> tag. IE ' + | ||||
'will not do the right thing with this.'); | 'will not do the right thing with this.'); | ||||
} | } | ||||
// TODO(epriestley): May need to deny <option> more broadly, see | // TODO: May need to deny <option> more broadly, see | ||||
// http://support.microsoft.com/kb/829907 and the whole mess in the | // http://support.microsoft.com/kb/829907 and the whole mess in the | ||||
// heavy stack. But I seem to have gotten away without cloning into the | // heavy stack. But I seem to have gotten away without cloning into the | ||||
// documentFragment below, so this may be a nonissue. | // documentFragment below, so this may be a nonissue. | ||||
} | } | ||||
this._content = str; | this._content = str; | ||||
}, | }, | ||||
members : { | members : { | ||||
_content : null, | _content : null, | ||||
/** | /** | ||||
* Convert the raw HTML string into a DOM node tree. | * Convert the raw HTML string into a DOM node tree. | ||||
* | * | ||||
* @task nodes | * @task nodes | ||||
* @return DocumentFragment A document fragment which contains the nodes | * @return DocumentFragment A document fragment which contains the nodes | ||||
* corresponding to the HTML string you provided. | * corresponding to the HTML string you provided. | ||||
*/ | */ | ||||
getFragment : function() { | getFragment : function() { | ||||
var wrapper = JX.$N('div'); | var wrapper = JX.$N('div'); | ||||
wrapper.innerHTML = this._content; | wrapper.innerHTML = this._content; | ||||
var fragment = document.createDocumentFragment(); | var fragment = document.createDocumentFragment(); | ||||
while (wrapper.firstChild) { | while (wrapper.firstChild) { | ||||
// TODO(epriestley): Do we need to do a bunch of cloning junk here? | // TODO: Do we need to do a bunch of cloning junk here? | ||||
// See heavy stack. I'm disconnecting the nodes instead; this seems | // See heavy stack. I'm disconnecting the nodes instead; this seems | ||||
// to work but maybe my test case just isn't extensive enough. | // to work but maybe my test case just isn't extensive enough. | ||||
fragment.appendChild(wrapper.removeChild(wrapper.firstChild)); | fragment.appendChild(wrapper.removeChild(wrapper.firstChild)); | ||||
} | } | ||||
return fragment; | return fragment; | ||||
}, | }, | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 863 Lines • Show Last 20 Lines |