aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bzpage.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 878ce87..f0b4242 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -419,15 +419,19 @@ BZPage.prototype.createNewButton = function createNewButton (location, after, pk
var originalLocation = this.doc.getElementById(location);
- if (after) {
- originalLocation.parentNode.insertBefore(newButton,
- originalLocation.nextSibling);
- originalLocation.parentNode.insertBefore(this.doc
- .createTextNode("\u00A0"), newButton);
- } else {
- originalLocation.parentNode.insertBefore(newButton, originalLocation);
- originalLocation.parentNode.insertBefore(this.doc
- .createTextNode("\u00A0"), originalLocation);
+ try {
+ if (after) {
+ originalLocation.parentNode.insertBefore(newButton,
+ originalLocation.nextSibling);
+ originalLocation.parentNode.insertBefore(this.doc
+ .createTextNode("\u00A0"), newButton);
+ } else {
+ originalLocation.parentNode.insertBefore(newButton, originalLocation);
+ originalLocation.parentNode.insertBefore(this.doc
+ .createTextNode("\u00A0"), originalLocation);
+ }
+ } catch (e if e instanceof TypeError) {
+ console.log("cannot find originalLocation element with id " + location);
}
};