lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.4.1 vs lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.5.0
- old
+ new
@@ -72,11 +72,11 @@
_results.push(this.register(el));
}
return _results;
} catch (_error) {
error = _error;
- if (error.code === DOMException.SYNTAX_ERR) {
+ if (error.code === DOMException.SYNTAX_ERR || error.code === 51) {
throw new PoltergeistAgent.InvalidSelector;
} else {
throw error;
}
}
@@ -231,10 +231,18 @@
} else {
return this.element.innerText;
}
};
+ Node.prototype.deleteText = function() {
+ var range;
+ range = document.createRange();
+ range.selectNodeContents(this.element);
+ window.getSelection().addRange(range);
+ return window.getSelection().deleteFromDocument();
+ };
+
Node.prototype.getAttribute = function(name) {
if (name === 'checked' || name === 'selected') {
return this.element[name];
} else {
return this.element.getAttribute(name);
@@ -270,16 +278,20 @@
if (this.element.maxLength >= 0) {
value = value.substr(0, this.element.maxLength);
}
this.element.value = '';
this.trigger('focus');
- for (_i = 0, _len = value.length; _i < _len; _i++) {
- char = value[_i];
- keyCode = this.characterToKeyCode(char);
- this.keyupdowned('keydown', keyCode);
- this.element.value += char;
- this.keypressed(false, false, false, false, char.charCodeAt(0), char.charCodeAt(0));
- this.keyupdowned('keyup', keyCode);
+ if (this.element.type === 'number') {
+ this.element.value = value;
+ } else {
+ for (_i = 0, _len = value.length; _i < _len; _i++) {
+ char = value[_i];
+ keyCode = this.characterToKeyCode(char);
+ this.keyupdowned('keydown', keyCode);
+ this.element.value += char;
+ this.keypressed(false, false, false, false, char.charCodeAt(0), char.charCodeAt(0));
+ this.keyupdowned('keyup', keyCode);
+ }
}
this.changed();
this.input();
return this.trigger('blur');
};