Commit 90ab53e3 90ab53e3b5219d4b3102107a19d3ee8712717bb5 by Matt Bowman

* Remove 'self' parameter from selectorFunctions

* Use 'call' to set the correct value for 'this' when invoking selectorFunctions
1 parent a329257b
......@@ -783,7 +783,7 @@ Casper.prototype.fillForm = function (selector, vals, options) {
if (!fs.exists(file.path)) {
throw new CasperError('Cannot upload nonexistent file: ' + file.path);
}
var fileFieldSelector = selectorFunction(self, file.name, selector).fullSelector;
var fileFieldSelector = selectorFunction.call(this, file.name, selector).fullSelector;
self.page.uploadFile(fileFieldSelector, file.path);
});
})(this);
......@@ -823,10 +823,10 @@ Casper.prototype.fillNames = function fillNames(formSelector, vals, submit) {
"use strict";
return this.fillForm(formSelector, vals, {
submit: submit,
selectorFunction: function _nameSelector(self, selector, form) {
selectorFunction: function _nameSelector(selector, form) {
return {
fullSelector: [form, '[name="' + selector + '"]'].join(' '),
elts: (self.findAll ? self.findAll('[name="' + selector + '"]', form) : null)
elts: (this.findAll ? this.findAll('[name="' + selector + '"]', form) : null)
};
}
});
......@@ -852,10 +852,10 @@ Casper.prototype.fillSelectors = function fillSelectors(formSelector, vals, subm
"use strict";
return this.fillForm(formSelector, vals, {
submit: submit,
selectorFunction: function _css3Selector(self, selector, form) {
selectorFunction: function _css3Selector(selector, form) {
return {
fullSelector: [form, selector].join(' '),
elts: (self.findAll ? self.findAll(selector, form) : null)
elts: (this.findAll ? this.findAll(selector, form) : null)
};
}
});
......
......@@ -209,10 +209,10 @@
files: []
};
findFunction = findFunction || function _nameSelector(self, name, form) {
findFunction = findFunction || function _nameSelector(name, form) {
return {
fullSelector: [form, '[name="' + name + '"]'].join(' '),
elts: self.findAll('[name="' + name + '"]', form)
elts: this.findAll('[name="' + name + '"]', form)
};
};
......@@ -235,7 +235,7 @@
if (!vals.hasOwnProperty(name)) {
continue;
}
var field = findFunction(this, name, form).elts;
var field = findFunction.call(this, name, form).elts;
var value = vals[name];
if (!field || field.length === 0) {
out.errors.push('no field named "' + name + '" in form');
......