Skip to content
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

Improve x-attributes regexp #234

Merged
merged 5 commits into from
Mar 7, 2020

Conversation

philippbosch
Copy link
Contributor

For debugging reasons I tried to disable an x-show by changing it to blah-x-show and was surprised it was still parsed like x-show.

The reason was that the regular expression used to filter all attributes was a bit too loose. My suggestion implemented in this PR is to:

  1. Make sure the attribute starts with x- and does not allow any extraneous characters before the x. This is done by adding a start of string anchor to the beginning: /^x-… instead of /x-…
  2. Make sure the directive type is matched exactly and does not allow any extraneous trailing characters (e.g. x-showblah). This is done by adding a word boundary (\b) to the end of the regexp. Using a word boundary instead of an end of string anchor ($) allows for values (:click) and modifiers (.prevent).

Any suggestions welcome and appreciated.

@calebporzio
Copy link
Collaborator

Thanks!

@calebporzio calebporzio merged commit 98d26e1 into alpinejs:master Mar 7, 2020
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.

2 participants