code snippet works when procedural, but doesn't when converted to modular
Posted
by Delirium tremens
on Stack Overflow
See other posts from Stack Overflow
or by Delirium tremens
Published on 2010-03-12T18:39:01Z
Indexed on
2010/03/12
19:17 UTC
Read the original article
Hit count: 301
JavaScript
|firefox
function sc_HTMLParser(aHTMLString){
var parseDOM = content.document.createElement('div');
parseDOM.appendChild(Components.classes['@mozilla.org/feed-unescapehtml;1']
.getService(Components.interfaces.nsIScriptableUnescapeHTML)
.parseFragment(aHTMLString, false, null, parseDOM));
return parseDOM;
}
becomes
this.HTMLParser = function(aHTMLString){
var parseDOM = content.document.createElement('div');
parseDOM.appendChild(Components.classes['@mozilla.org/feed-unescapehtml;1']
.getService(Components.interfaces.nsIScriptableUnescapeHTML)
.parseFragment(aHTMLString, false, null, parseDOM));
return parseDOM;
}
and
searchcontents = req.responseText;
parsedHTML = sc_HTMLParser(searchcontents);
sitefound = sc_sitefound(compareuris, parsedHTML);
becomes
searchcontents = req.responseText;
alert(searchcontents);
parsedHTML = this.HTMLParser(searchcontents);
alert(parsedHTML);
sitefound = this.sitefound(compareuris, parsedHTML);
The modular code alerts the search contents, but doesn't alert the parsedHTML. Why? How to solve?
© Stack Overflow or respective owner