From 2631419202197d3686f26d0158f9bf5019f75d63 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 17:40:50 -0700 Subject: [PATCH 1/3] in Firefox 3.6 on amd64 Ubuntu that I tested, setting innerHTML of TBODY to "..." doesn't just add a TR, and Firefox tries to fix it to something broken. But setting innerHTML of a TABLE to "..." works as expected. --- .../main/webapp/scripts/hudson-behavior.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 124bab0c1f..8ed77352d2 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -433,17 +433,30 @@ function renderOnDemand(e,callback,noBehaviour) { if (!e || !Element.hasClassName(e,"render-on-demand")) return; var proxy = eval(e.getAttribute("proxy")); proxy.render(function (t) { - var c = document.createElement(e.parentNode.tagName); - c.innerHTML = t.responseText; + var contextTagName = e.parentNode.tagName; + var c; + if (contextTagName=="TBODY") { + c = document.createElement("TABLE"); + c.innerHTML = t.responseText; + if (c.firstChild && c.firstChild.tagName=="TBODY") + c = c.firstChild; + } else { + c = document.createElement(contextTagName); + c.innerHTML = t.responseText; + } + var elements = []; while (c.firstChild!=null) { var n = c.firstChild; e.parentNode.insertBefore(n,e); if (n.nodeType==1 && !noBehaviour) - Behaviour.applySubtree(n,true); + elements.push(n); } Element.remove(e); + t.responseText.evalScripts(); + elements.each(function(n) { Behaviour.applySubtree(n,true); }); + if (callback) callback(t); }); } From 9080a7215be6502a9c734f0d97a22780b8bc70a5 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 17:53:21 -0700 Subject: [PATCH 2/3] in IE, innerHTML of TABLE is not modifiable (See http://support.microsoft.com/kb/239832), so this doesn't work. Looking at the similar code in the latest prototype.js, a work around is to create the full TABLE HTML fragment and inserting it to DIV. --- war/src/main/webapp/scripts/hudson-behavior.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 8ed77352d2..8c233bf416 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -436,10 +436,9 @@ function renderOnDemand(e,callback,noBehaviour) { var contextTagName = e.parentNode.tagName; var c; if (contextTagName=="TBODY") { - c = document.createElement("TABLE"); - c.innerHTML = t.responseText; - if (c.firstChild && c.firstChild.tagName=="TBODY") - c = c.firstChild; + c = document.createElement("DIV"); + c.innerHTML = ""+t.responseText+"
"; + c = c.firstChild.firstChild; } else { c = document.createElement(contextTagName); c.innerHTML = t.responseText; From 803d111642689ef7456006ccd21ff5c101859592 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 14 Mar 2011 18:10:00 -0700 Subject: [PATCH 3/3] on IE8, element always gets empty string as name, not null. Empty name is not valid any way, so detect that accordingly. --- war/src/main/webapp/scripts/hudson-behavior.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 8c233bf416..8b9b1720b4 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -1672,7 +1672,7 @@ function findFormParent(e,form,static) { return null; // this field shouldn't contribute to the final result var name = e.getAttribute("name"); - if(name!=null) { + if(name!=null && name.length>0) { if(e.tagName=="INPUT" && !static && !xor(e.checked,Element.hasClassName(e,"negative"))) return null; // field is not active