[Pkg-mozext-commits] [itsalltext] 69/459: Deal with duplicate name attributes that don't have an id
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository itsalltext.
commit 6babb98728ddb3b017672367147ac1340d31b671
Author: docwhat at gerf.org <docwhat at gerf.org>
Date: Wed Jan 10 12:48:27 2007 -0500
Deal with duplicate name attributes that don't have an id
---
chrome/content/itsalltext.js | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index b38f3fe..818b918 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -258,14 +258,22 @@ function ItsAllTextOverlay() {
* @returns {String} the unique identifier.
*/
that.getNodeIdentifier = function(node) {
- // @todo getNodeIdentifier() - if result isn't unque enough, add id to node.
- var name = node.getAttribute('name');
var id = node.getAttribute('id');
- if (id) {
- return id;
- } else {
- return name;
+ if (!id) {
+ var name = node.getAttribute('name');
+ var doc = node.ownerDocument.getElementsByTagName('html')[0];
+ var attr = MYSTRING+'_id_serial';
+
+ /* Get a serial that's unique to this document */
+ var serial = doc.getAttribute(attr);
+ if (serial) { serial = parseInt(serial)+1;
+ } else { serial = 1; }
+ id = [MYSTRING,'generated_id',name,serial].join('_');
+ doc.setAttribute(attr,serial);
+
+ node.setAttribute('id',id);
}
+ return id;
};
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git
More information about the Pkg-mozext-commits
mailing list