Skip to content

Commit 6c55320

Browse files
committed
Use \s in the regex for better readability.
This also escapes other whitespace. Hopefully nobody in the world is intentionally putting newlines in their ID attributes, but if they are, we should be behaving correctly for that case now.
1 parent 8f074b5 commit 6c55320

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • javascript/atoms/locators

javascript/atoms/locators/id.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ bot.locators.id.many = function(target, root) {
9696
* Given a string, escapes all the characters that have special meaning in CSS.
9797
* https://mathiasbynens.be/notes/css-escapes
9898
*
99-
* An ID can contain anything but spaces, but we also escape spaces because some
100-
* webpages use spaces, and getElementById allows spaces in every browser.
99+
* An ID can contain anything but spaces, but we also escape whitespace because
100+
* some webpages use spaces, and getElementById allows spaces in every browser.
101101
* http://www.w3.org/TR/html5/dom.html#the-id-attribute
102102
*
103103
* This could be further improved, perhaps by using
@@ -110,5 +110,5 @@ bot.locators.id.many = function(target, root) {
110110
*/
111111
bot.locators.id.cssEscape_ = function(s) {
112112
// One backslash escapes things in a regex statement; we need two in a string.
113-
return s.replace(/([ '"\\#.:;,!?+<>=~*^$|%&@`{}\-\/\[\]\(\)])/g, '\\$1');
113+
return s.replace(/([\s'"\\#.:;,!?+<>=~*^$|%&@`{}\-\/\[\]\(\)])/g, '\\$1');
114114
};

0 commit comments

Comments
 (0)