From 408dba191050487c6320523b9130e0a265a948d5 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Wed, 13 Oct 2010 20:05:23 -0400 Subject: [PATCH] read_browser_object: throw error when there is no object to read As of this patch, null is officially defined as a valid browser object. All commands which call read_browser_object must supply a default via the $browser_object keyword. The commands 'scroll' and 'reload' have been updated to supply a default of null. The interactive error "No browser object" is thrown when the interactive context's browser object is 'undefined'. --- modules/content-buffer.js | 3 ++- modules/element.js | 3 +++ modules/input.js | 2 +- modules/interactive.js | 8 ++++---- modules/scroll.js | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/content-buffer.js b/modules/content-buffer.js index dab886d..46ece7b 100644 --- a/modules/content-buffer.js +++ b/modules/content-buffer.js @@ -572,7 +572,8 @@ interactive("reload", check_buffer(I.buffer, content_buffer); var element = yield read_browser_object(I); reload(I.buffer, I.P, element, I.forced_charset); - }); + }, + $browser_object = null); /** * browserDOMWindow: intercept window opening diff --git a/modules/element.js b/modules/element.js index a3d8b3e..b0891aa 100644 --- a/modules/element.js +++ b/modules/element.js @@ -286,6 +286,9 @@ interactive("browser-object-text", function read_browser_object (I) { var browser_object = I.browser_object; + if (browser_object === undefined) + throw interactive_error("No browser object"); + var result; // literals cannot be overridden if (browser_object instanceof Function) { diff --git a/modules/input.js b/modules/input.js index dc78a7f..ccfd080 100644 --- a/modules/input.js +++ b/modules/input.js @@ -221,7 +221,7 @@ sequence: event_kill(event); if (binding) { - if (binding.browser_object != null) + if (binding.browser_object !== undefined) I.binding_browser_object = binding.browser_object; if (binding.constructor == Array) { keymaps = binding; diff --git a/modules/interactive.js b/modules/interactive.js index a6e6988..a44238c 100644 --- a/modules/interactive.js +++ b/modules/interactive.js @@ -108,21 +108,21 @@ function call_interactively (I, command) { // if there was no interactive browser-object, // binding_browser_object becomes the default. - if (I.browser_object == null) { + if (I.browser_object === undefined) { I.browser_object = 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 && + if (cmd.browser_object !== undefined && (! (cmd.browser_object instanceof browser_object_class)) && - (I.binding_browser_object == null)) + (I.binding_browser_object === undefined)) { I.browser_object = cmd.browser_object; } // if we still have no browser-object, look for a page-mode // default, or finally the command default. - if (I.browser_object == null) { + if (I.browser_object === undefined) { I.browser_object = (I.buffer && I.buffer.default_browser_object_classes[command]) || cmd.browser_object; diff --git a/modules/scroll.js b/modules/scroll.js index a07d470..ad00199 100644 --- a/modules/scroll.js +++ b/modules/scroll.js @@ -93,6 +93,7 @@ interactive("scroll", "the object passed to the command as a browser-object. If the object "+ "is a DOM node, that node will be scrolled to the top of the viewport "+ "if possible.", - scroll); + scroll, + $browser_object = null); provide("scroll"); -- 2.11.4.GIT