From 999fe5ef1559a19a0ef21dfc34729581196e3ebc Mon Sep 17 00:00:00 2001 From: umbrae Date: Sat, 7 Mar 2009 14:34:21 +0000 Subject: Remove any root styles from an element git-svn-id: http://arc90labs-readability.googlecode.com/svn/trunk@12 d4e419ec-0920-11de-bbfd-a7c1bc4c261e --- js/readability-0.1.js | 9 +++++---- 1 file 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 ) { -- cgit v1.2.3