This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix a few issues with Browser#find and Node#get.

  • Loading branch information...
tristandunn committed Mar 13, 2012
1 parent c1453d7 commit f925d9234fdf3e89149dcf0cbcaa4b21fa5e848f
Showing with 9 additions and 5 deletions.
  1. +3 −3 lib/browser.js
  2. +6 −2 lib/node.js
View
@@ -38,15 +38,15 @@ Browser.prototype.execute = function(code, callback) {
Browser.prototype.find = function(selector, callback) {
this.command("Find", selector, function(error, ids) {
if (error) {
- return callback(error);
+ return callback.call(this, error);
} else if (ids.length > 0) {
var nodes = ids.split(',').map(function(id) {
return new Node(id, this);
}.bind(this));
}
- callback(undefined, nodes || []);
- }.bind(this));
+ callback.call(this, undefined, nodes || []);
+ });
};
Browser.prototype.headers = function(callback) {
View
@@ -4,12 +4,16 @@ var Node = module.exports = function(id, browser) {
};
Node.prototype.get = function(name, callback) {
- this.invoke("attribute", name, function(value) {
+ this.invoke("attribute", name, function(error, value) {
+ if (error) {
+ return callback.call(this, error);
+ }
+
if (name == "checked" || name == "disabled") {
value = (value == "true");
}
- callback(value);
+ callback.call(this, undefined, value);
});
};

0 comments on commit f925d92

Please sign in to comment.