[gnome-maps] Layers: Fix warnings in xmldom



commit b50bb771f368521f53c977ffaf7a47335bf22204
Author: Hashem Nasarat <hashem riseup net>
Date:   Mon Feb 15 01:18:33 2016 -0500

    Layers: Fix warnings in xmldom
    
    There were several errors from returning with "return" when to be
    pedantic, the functions should "return none". Also functions should only
    be declared at top level.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757171

 src/xmldom/dom.js       |   52 +++++++++++++++++++++++++---------------------
 src/xmldom/domparser.js |    7 +++--
 src/xmldom/sax.js       |    3 +-
 3 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/src/xmldom/dom.js b/src/xmldom/dom.js
index 8e64087..1963067 100644
--- a/src/xmldom/dom.js
+++ b/src/xmldom/dom.js
@@ -21,7 +21,7 @@ function _extends(Class,Super){
                pt.__proto__ = ppt;
        }
        if(!(pt instanceof Super)){
-               function t(){};
+               let t = function (){};
                t.prototype = Super.prototype;
                t = new t();
                copy(pt,t);
@@ -152,6 +152,7 @@ function _findNodeIndex(list,node){
        while(i--){
                if(list[i] === node){return i}
        }
+       return null;
 }
 
 function _addNamedNode(el,list,newAttr,oldAttr){
@@ -202,6 +203,7 @@ NamedNodeMap.prototype = {
                                return attr;
                        }
                }
+               return null;
        },
        setNamedItem: function(attr) {
                var el = attr.ownerElement;
@@ -426,11 +428,12 @@ function _visitNode(node,callback){
        if(callback(node)){
                return true;
        }
-       if(node = node.firstChild){
+       if((node = node.firstChild)){
                do{
                        if(_visitNode(node,callback)){return true}
-        }while(node=node.nextSibling)
+        }while((node=node.nextSibling))
     }
+       return false;
 }
 
 
@@ -605,6 +608,7 @@ Document.prototype = {
                                        return true;
                                }
                        }
+                       return false;
                })
                return rtv;
        },
@@ -948,7 +952,7 @@ function serializeToString(node,buf,attributeSorter,isHTML){
                }else{
                        buf.push('/>');
                }
-               return;
+               return null;
        case DOCUMENT_NODE:
        case DOCUMENT_FRAGMENT_NODE:
                var child = node.firstChild;
@@ -956,7 +960,7 @@ function serializeToString(node,buf,attributeSorter,isHTML){
                        serializeToString(child,buf,attributeSorter,isHTML);
                        child = child.nextSibling;
                }
-               return;
+               return null;
        case ATTRIBUTE_NODE:
                return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
        case TEXT_NODE:
@@ -984,7 +988,7 @@ function serializeToString(node,buf,attributeSorter,isHTML){
                        }
                        buf.push(">");
                }
-               return;
+               return null;
        case PROCESSING_INSTRUCTION_NODE:
                return buf.push( "<?",node.target," ",node.data,"?>");
        case ENTITY_REFERENCE_NODE:
@@ -992,7 +996,7 @@ function serializeToString(node,buf,attributeSorter,isHTML){
        //case ENTITY_NODE:
        //case NOTATION_NODE:
        default:
-               buf.push('??',node.nodeName);
+               return buf.push('??',node.nodeName);
        }
 }
 function importNode(doc,node,deep){
@@ -1084,6 +1088,23 @@ function __set__(object,key,value){
        object[key] = value
 }
 //do dynamic
+function getTextContent(node){
+       switch(node.nodeType){
+       case 1:
+       case 11:
+               var buf = [];
+               node = node.firstChild;
+               while(node){
+                       if(node.nodeType!==7 && node.nodeType !==8){
+                               buf.push(getTextContent(node));
+                       }
+                       node = node.nextSibling;
+               }
+               return buf.join('');
+       default:
+               return node.nodeValue;
+       }
+}
 try{
        if(Object.defineProperty){
                Object.defineProperty(LiveNodeList.prototype,'length',{
@@ -1116,23 +1137,6 @@ try{
                        }
                })
                
-               function getTextContent(node){
-                       switch(node.nodeType){
-                       case 1:
-                       case 11:
-                               var buf = [];
-                               node = node.firstChild;
-                               while(node){
-                                       if(node.nodeType!==7 && node.nodeType !==8){
-                                               buf.push(getTextContent(node));
-                                       }
-                                       node = node.nextSibling;
-                               }
-                               return buf.join('');
-                       default:
-                               return node.nodeValue;
-                       }
-               }
                __set__ = function(object,key,value){
                        //console.log(value)
                        object['$$'+key] = value
diff --git a/src/xmldom/domparser.js b/src/xmldom/domparser.js
index 09941f6..10bc45b 100644
--- a/src/xmldom/domparser.js
+++ b/src/xmldom/domparser.js
@@ -93,9 +93,9 @@ DOMHandler.prototype = {
            
                this.locator && position(this.locator,el)
            for (var i = 0 ; i < len; i++) {
-               var namespaceURI = attrs.getURI(i);
+               namespaceURI = attrs.getURI(i);
                var value = attrs.getValue(i);
-               var qName = attrs.getQName(i);
+               qName = attrs.getQName(i);
                        var attr = doc.createAttributeNS(namespaceURI, qName);
                        if( attr.getOffset){
                                position(attr.getOffset(1),attr)
@@ -140,7 +140,7 @@ DOMHandler.prototype = {
                this.document.normalize();
        },
        setDocumentLocator:function (locator) {
-           if(this.locator = locator){// && !('lineNumber' in locator)){
+           if((this.locator = locator)){// && !('lineNumber' in locator)){
                locator.lineNumber = 0;
            }
        },
@@ -188,6 +188,7 @@ function _locator(l){
        if(l){
                return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
        }
+       return null;
 }
 function _toString(chars,start,length){
        if(typeof chars == 'string'){
diff --git a/src/xmldom/sax.js b/src/xmldom/sax.js
index c771be3..9be75bf 100644
--- a/src/xmldom/sax.js
+++ b/src/xmldom/sax.js
@@ -574,8 +574,9 @@ function split(source,start){
        var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
        reg.lastIndex = start;
        reg.exec(source);//skip <
-       while(match = reg.exec(source)){
+       while((match = reg.exec(source))){
                buf.push(match);
                if(match[1])return buf;
        }
+       return null;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]