Escape spaces in ID locators.
Spaces aren't legal characters in IDs, but the singular locator (bot.locators.id.single) accepts them, as does document.getElementById in every browser, so the plural locator should work for the sake of consistency.
@@ -79,8 +79,7 @@ bot.locators.id.many = function(target, root) {
}
if (bot.locators.id.canUseQuerySelector_(root, target)) {
try {
- // ID can contain anything but spaces. Need to escape for CSS selector.
- // http://www.w3.org/TR/html5/dom.html#the-id-attribute
+ // Need to escape the ID for use in a CSS selector.
return root.querySelectorAll('#' + bot.locators.id.cssEscape_(target));
} catch (e) {
return [];
@@ -97,6 +96,10 @@ bot.locators.id.many = function(target, root) {
* Given a string, escapes all the characters that have special meaning in CSS.
* https://mathiasbynens.be/notes/css-escapes
*
+ * An ID can contain anything but spaces, but we also escape spaces because some
+ * webpages use spaces, and getElementById allows spaces in every browser.
+ * http://www.w3.org/TR/html5/dom.html#the-id-attribute
+ *
* This could be further improved, perhaps by using
* http://dev.w3.org/csswg/cssom/#the-css.escape()-method , where implemented,
* or a polyfill such as https://github.com/mathiasbynens/CSS.escape.
