diff options
| author | jez | 2010-12-31 05:58:26 +0800 | 
|---|---|---|
| committer | jez | 2010-12-31 05:58:31 +0800 | 
| commit | 489ff3f8f0f7b44817a09472b5b1e2fad46d7632 (patch) | |
| tree | 47e5e75ebbb546a0b1faefa630d6b7c069296455 /vimiumFrontend.js | |
| parent | 09a959e97a260bc359bdcbadea814cd436691837 (diff) | |
| download | vimium-489ff3f8f0f7b44817a09472b5b1e2fad46d7632.tar.bz2 | |
Use 'this' instead of 'linkHints' where possible.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 22 | 
1 files changed, 11 insertions, 11 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 95b6a023..dac778cb 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -79,25 +79,25 @@ function initializePreDomReady() {      sendResponse({}); // Free up the resources used by this open connection.    }); -  // takes a dot-notation object string and returns the member it points to -  function resolveCommandString(str) { +  // takes a dot-notation object string and call the function +  // that it points to with the correct value for 'this'. +  function invokeCommandString(str, argArray) {      var components = str.split('.'); -    var component; -    var func = this[components.shift()]; -    while ((component = components.shift()) && func) -      func = func[component]; -    return func; +    var obj = this; +    for (var i = 0; i < components.length - 1; i++) +      obj = obj[components[i]]; +    var func = obj[components.pop()]; +    return func.apply(obj, argArray);    }    chrome.extension.onConnect.addListener(function(port, name) {      if (port.name == "executePageCommand") {        port.onMessage.addListener(function(args) { -        func = resolveCommandString(args.command); -        if (func && frameId == args.frameId) { +        if (frameId == args.frameId) {            if (args.passCountToFunction) { -            func.call(null, args.count); +            invokeCommandString(args.command, [args.count]);            } else { -            for (var i = 0; i < args.count; i++) { func(); } +            for (var i = 0; i < args.count; i++) { invokeCommandString(args.command); }            }          }  | 
