[kupu-checkins] r46935 - kupu/trunk/kupu/common
duncan at codespeak.net
duncan at codespeak.net
Thu Sep 27 11:39:10 CEST 2007
Author: duncan
Date: Thu Sep 27 11:39:10 2007
New Revision: 46935
Modified:
kupu/trunk/kupu/common/kupudrawers.js
kupu/trunk/kupu/common/kupuhelpers.js
Log:
Anchors weren't always picking up the associated text correctly.
Reference browser was getting a js error on initialisation.
Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js (original)
+++ kupu/trunk/kupu/common/kupudrawers.js Thu Sep 27 11:39:10 2007
@@ -246,18 +246,16 @@
var blocktag = /^DIV|P|BODY|TD|H.$/;
var txt = '';
var prefix = '#' + a.name;
-findlabel:
+
for (var node = a; node && !txt; node=node.parentNode) {
var txt = node.textContent || node.innerText || '';
if (txt || blocktag.test(node.nodeName)) {
break;
}
- for (var sibling = node.nextSibling; sibling; sibling = sibling.nextSibling) {
+ for (var sibling = node.nextSibling; sibling && !txt; sibling = sibling.nextSibling) {
if (sibling.nodeName=='#text') {
txt = sibling.data.strip();
- } else if (blocktag.test(sibling.nodeName)) {
- break findlabel;
} else {
txt += sibling.textContent || sibling.innerText ||'';
};
Modified: kupu/trunk/kupu/common/kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/common/kupuhelpers.js (original)
+++ kupu/trunk/kupu/common/kupuhelpers.js Thu Sep 27 11:39:10 2007
@@ -969,12 +969,16 @@
};
this.getRange = function() {
- return this.selection.getRangeAt(0);
+ if (this.selection) {
+ return this.selection.getRangeAt(0);
+ }
};
this.restoreRange = function(range) {
var selection = this.selection;
- selection.removeAllRanges();
- selection.addRange(range);
+ if (selection) {
+ selection.removeAllRanges();
+ selection.addRange(range);
+ }
};
//sample kindly snipped from Mozilla's wiki
More information about the kupu-checkins
mailing list