Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
need to normalize to upper case
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Feb 4, 2014
1 parent 6254771 commit 20a2313
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var nodesAddedHandler = function(nodeList, summary) {
var i = 0;
var node, src, text;
while ( node = nodeList.item(i++) ) {
switch ( node.tagName ) {
switch ( node.tagName.toUpperCase() ) {

This comment has been minimized.

Copy link
@my-password-is-password

my-password-is-password Feb 4, 2014

Contributor

Before the switch can you check to see what's the node.nodeType and continue for non ELEMENT_NODE (1); . http://dom.spec.whatwg.org/#dom-node-nodetype

TEXT_NODE(3) have tagName undefined

and you get this error: Uncaught TypeError: Cannot call method 'toUpperCase' of undefined

Go to http://www.youtube.com/ and you can see TEXT_NODE (3).

And on line 128 can you change nodesAddedHandler(mutation.addedNodes, summary);
to be

if( mutation.addedNodes.length > 0 ) {
    nodesAddedHandler(mutation.addedNodes, summary);
}

When elements are being removed its still calling nodesAddedHandler. Just to avoid making the call.

This comment has been minimized.

Copy link
@gorhill

gorhill Feb 4, 2014

Author Owner

Thanks for spotting that, this will save regression bugs. Fixed in e455900.


case 'SCRIPT':
text = node.textContent.trim();
Expand Down

0 comments on commit 20a2313

Please sign in to comment.