summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorumbrae <umbrae@d4e419ec-0920-11de-bbfd-a7c1bc4c261e>2009-03-07 14:34:21 +0000
committerumbrae <umbrae@d4e419ec-0920-11de-bbfd-a7c1bc4c261e>2009-03-07 14:34:21 +0000
commit999fe5ef1559a19a0ef21dfc34729581196e3ebc (patch)
treef1d8c191ac5f2ae8bcb9ed45242fa2780d140c2c
parente57dbe286243788a6d1768fc3215d4f9ba1108e4 (diff)
downloadreadability-simple-999fe5ef1559a19a0ef21dfc34729581196e3ebc.tar.bz2
readability-simple-999fe5ef1559a19a0ef21dfc34729581196e3ebc.zip
Remove any root styles from an element
git-svn-id: http://arc90labs-readability.googlecode.com/svn/trunk@12 d4e419ec-0920-11de-bbfd-a7c1bc4c261e
-rwxr-xr-xjs/readability-0.1.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/js/readability-0.1.js b/js/readability-0.1.js
index 9397687..6c255e6 100755
--- a/js/readability-0.1.js
+++ b/js/readability-0.1.js
@@ -92,11 +92,9 @@ function grabArticle() {
*/
}
- allNodes = document.getElementsByTagName("*");
- for(nodeIndex = 0; nodeIndex < allNodes.length; nodeIndex++)
+ /* Assignment from index for performance. See http://www.peachpit.com/articles/article.aspx?p=31567&seqNum=5 */
+ for(nodeIndex = 0; (node = document.getElementsByTagName('*')[nodeIndex]); nodeIndex++)
{
- node = allNodes[nodeIndex];
-
if(typeof node.readability != 'undefined')
{
dbg('Found a node with a content score of ' + node.readability.contentScore);
@@ -158,6 +156,9 @@ function cleanStyles( e ) {
e = e || document;
var cur = e.firstChild;
+ // Remove any root styles
+ e.removeAttribute('style');
+
// Go until there are no more child nodes
while ( cur != null ) {
if ( cur.nodeType == 1 ) {