Previously there was a strange exception, where the presence of a
binding browser object would prevent a command browser object that is
non-null literal from overriding the choice.

Relates: http://bugs.conkeror.org/issue375
---
 modules/element.js                        |   37 ++++++++++------------------
 tests/simple/browser-object-precedence.js |    4 +--
 2 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/modules/element.js b/modules/element.js
index 2c963bc..af6be5b 100644
--- a/modules/element.js
+++ b/modules/element.js
@@ -289,32 +289,21 @@ interactive("browser-object-text",
     $prefix);
 
 function get_browser_object (I) {
-    var obj = I.browser_object;
     var cmd = I.command;
 
-    // if there was no interactive browser-object,
-    // binding_browser_object becomes the default.
-    if (obj === undefined) {
-        obj = I.binding_browser_object;
-    }
-    // if the command's default browser object is a non-null literal,
-    // it overrides an interactive browser-object, but not a binding
-    // browser object.
-    if (cmd.browser_object != null &&
-        (! (cmd.browser_object instanceof browser_object_class)) &&
-        (I.binding_browser_object === undefined))
-    {
-        obj = cmd.browser_object;
-    }
-    // if we still have no browser-object, look for a page-mode
-    // default, or finally the command default.
-    if (obj === undefined) {
-        obj = (I.buffer &&
-               I.buffer.default_browser_object_classes[cmd.name]) ||
-            cmd.browser_object;
-    }
-
-    return obj;
+    return undefined ||
+        // 1. A non-null literal command default.
+        (! (cmd.browser_object instanceof browser_object_class) &&
+         cmd.browser_object) ||
+        // 2. An interactively specified browser object.
+        I.browser_object ||
+        // 3. A binding default.
+        I.binding_browser_object ||
+        // 4. A page mode default.
+        (I.buffer &&
+         I.buffer.default_browser_object_classes[cmd.name]) ||
+        // 5. A command default (of any kind).
+        cmd.browser_object;
 }
 
 function read_browser_object (I) {
diff --git a/tests/simple/browser-object-precedence.js 
b/tests/simple/browser-object-precedence.js
index c8d0320..5956b9e 100644
--- a/tests/simple/browser-object-precedence.js
+++ b/tests/simple/browser-object-precedence.js
@@ -34,7 +34,6 @@ require('keywords.js');
       },
       test_get_browser_object_binding: function () {
           test("b", $binding = "b", $command = browser_object_links);
-          test("b", $binding = "b", $command = "c");
           test("b", $binding = "b", $page_mode = "p");
       },
       test_get_browser_object_page_mode: function () {
@@ -44,8 +43,7 @@ require('keywords.js');
           test(browser_object_links, $command = browser_object_links);
           test("c", $command = "c", $page_mode = "p");
           test("c", $command = "c", $interactive = "i");
-          // Strange case:
-          test("i", $command = "c", $interactive = "i", $binding = "b");
+          test("c", $command = "c", $binding = "b");
       },
   };
   walnut_run(suite);
-- 
1.7.7

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to