- From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 29 Apr 2011 13:52:14 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv5644/js Modified Files: respec.js simple-node.js Log Message: first step in fixing the ID bug on overloaded methods Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.146 retrieving revision 1.147 diff -u -d -r1.146 -r1.147 --- respec.js 28 Apr 2011 08:25:11 -0000 1.146 +++ respec.js 29 Apr 2011 13:52:12 -0000 1.147 @@ -2007,6 +2007,8 @@ var dl = sn.element("dl", { "class": type + "s" }, sec); for (var j = 0; j < things.length; j++) { var it = things[j]; + var id = sn.idThatDoesNotExist(curLnk + it.refId); + console.log("ID=" + id); var dt = sn.element("dt", { id: curLnk + it.refId }, dl); sn.element("code", {}, dt, it.id); var desc = sn.element("dd", {}, dl, [it.description]); Index: simple-node.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/simple-node.js,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- simple-node.js 28 Aug 2009 13:20:48 -0000 1.6 +++ simple-node.js 29 Apr 2011 13:52:12 -0000 1.7 @@ -118,12 +118,19 @@ if (id.length > 0 && /^[^a-z]/.test(id)) id = "x" + id; if (id.length == 0) id = "generatedID"; if (pfx) id = pfx + "-" + id; + id = this.idThatDoesNotExist(id); + el.setAttribute("id", id); + return id; + }, + + idCache: {}, + idThatDoesNotExist: function (id) { var inc = 1; - if (this.doc.getElementById(id)) { - while (this.doc.getElementById(id + "-" + inc)) inc++; + if (this.doc.getElementById(id) || this.idCache[id]) { + while (this.doc.getElementById(id + "-" + inc) || this.idCache[id + "-" + inc]) inc++; id = id + "-" + inc; } - el.setAttribute("id", id); + this.idCache[id] = true; return id; },
Received on Friday, 29 April 2011 13:52:15 UTC