Skip to content

Fixes Regex to stop '.A' class from being added in escapeValue() #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kruggeri
Copy link

@kruggeri kruggeri commented Mar 26, 2018

Current Behavior

When Optimal Select discovers a CSS attribute (i.e. class) with a line break in it, the regex replaces the line with an ".A" class name.

Our company stumbled on this instance when using a client's site which had the following odd class name:

class="threeColumn product
   lastColumn"

Optimal Select's regex stripped the line break but returned a CSS Selector with threeColumn.product.A.lastColumn

I believe the function's original intention was to remove space until the beginning of the string, using the \A regex boundary. But, as we discovered, it returns a literal '.A' class.

Why do we need this change?

To prevent incorrect CSS selectors.

Implementation Details

By using an empty string for the regex, we can select the correct element. The fix worked very well for us and we hope it could save others some trouble.

@kruggeri kruggeri changed the title Kr+mt/fix escape value Fixes regex to stop '.A' class being added in escapeValue() Mar 26, 2018
@kruggeri kruggeri changed the title Fixes regex to stop '.A' class being added in escapeValue() Fixes Regex to Stop '.A' class from being added in escapeValue() Mar 26, 2018
@kruggeri kruggeri changed the title Fixes Regex to Stop '.A' class from being added in escapeValue() Fixes Regex to stop '.A' class from being added in escapeValue() Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant