[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 316/483: Topic 7101 - Better selection of pre-checked attributes, don't select empty id or class attributes
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.
commit 42a5dbabacc49f189d765114ea2bf77a009447f6
Author: Wladimir Palant <trev at adblockplus.org>
Date: Thu Mar 17 08:32:54 2011 +0100
Topic 7101 - Better selection of pre-checked attributes, don't select empty id or class attributes
---
chrome/content/composer.js | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index 894d6a9..c497e44 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -172,26 +172,29 @@ function init() {
nodeData = new NodeData(element);
nodeData.tagName.checked = true;
- if (nodeData.attributes.length > 0) {
- if (nodeData.attributes[0].name == "id" || nodeData.attributes[0].name == "class") {
- nodeData.attributes[0].selected = nodeData.attributes[0].value;
- nodeData.attributes[0].checked = true;
- nodeData.tagName.checked = false;
- }
- else {
- var maxLen = 0;
- var bestAttr = null;
- for (var i = 0; i < nodeData.attributes.length; i++) {
- if (nodeData.attributes[i].value.length > maxLen) {
- maxLen = nodeData.attributes[i].value.length;
- bestAttr = nodeData.attributes[i];
- }
+ if (nodeData.attributes.length > 0)
+ {
+ let maxLen = 0;
+ let bestAttr = null;
+ for (let i = 0; i < nodeData.attributes.length; i++)
+ {
+ let len = nodeData.attributes[i].value.length;
+ if ((nodeData.attributes[i].name == "id" || nodeData.attributes[i].name == "class") && len)
+ {
+ len = 0x7FFFFFFF;
+ nodeData.tagName.checked = false;
}
- if (bestAttr) {
- bestAttr.selected = bestAttr.value;
- bestAttr.checked = true;
+ if (len > maxLen)
+ {
+ maxLen = len;
+ bestAttr = nodeData.attributes[i];
}
}
+ if (bestAttr)
+ {
+ bestAttr.selected = bestAttr.value;
+ bestAttr.checked = true;
+ }
}
let domain = wnd.location.hostname;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git
More information about the Pkg-mozext-commits
mailing list