Explorar o código

root fixes for getElementsByName

Ivan Asmer %!s(int64=8) %!d(string=hai) anos
pai
achega
ab8ecb1474
Modificáronse 2 ficheiros con 10 adicións e 10 borrados
  1. 9 9
      static/index.js
  2. 1 1
      static/nb.js

+ 9 - 9
static/index.js

@@ -55,20 +55,20 @@ setTimeout(function(){
 
 //    $s.textarea; $s.select; $s.dzen; $s.check1; $s.note; $s.married; //just for init
     function btnDel(){
-        var arr = $s.hashTable.slice();
-        var thisLine = this.parentElement.parentElement;
-        arr.splice(thisLine.rowIndex -1,1)
-        $s.hashTable = arr;
-        $s.btnDel = {onclick: btnDel};
+        var arr = $s.hashTable.slice(); //copy
+        var thisLine = this.parentElement.parentElement; //current row
+        arr.splice(thisLine.rowIndex -1,1) //cut one row
+        $s.hashTable = arr; //set
+        $s.btnDel = {onclick: btnDel}; //update del button handlers
         //document.onchange();
     };
     $s.btnDel = {onclick: btnDel};
 
     $s.addPerson = {onclick: function(){
-        var arr = $s.hashTable.slice();
-        arr.push(Object.assign({},arr[0]))
-        $s.hashTable = arr;
-        $s.btnDel = {onclick: btnDel};
+        var arr = $s.hashTable.slice(); //copy
+        arr.push(Object.assign({},arr[0])) //add new row
+        $s.hashTable = arr; //set
+        $s.btnDel = {onclick: btnDel}; //update del button handlers
 
             
         

+ 1 - 1
static/nb.js

@@ -24,7 +24,7 @@ function nbInit(a,b){
             items = root.querySelectorAll("#" + selector); 
         }
         items     = items[0]     ? items :  root.querySelectorAll(selector);
-        items     = items.length ? items :  root.getElementsByName(selector); 
+        items     = items.length ? items :  root === document ? root.getElementsByName(selector) ? root.querySelectorAll("['name'='" + selector + "']"); 
         items     = items.length ? items :  root.getElementsByClassName(selector); 
         return items;
     }