marko-js-archive / marko-widgets

[LEGACY] Module to support binding of behavior to rendered UI components rendered on the server or client
http://v3.markojs.com/docs/marko-widgets/
MIT License
141 stars 40 forks source link

this.$() breaks when passing an attribute selector with '#' in it #128

Closed merwan7 closed 8 years ago

merwan7 commented 8 years ago

In Marko Widgets, if I use something like this:

this.$('[href="#jumpLink"]')

I get no results. The reason is because the idRegExp regular expression used in lib/Widget.js is matching it as an ID.

Since Javascript regular expressions don't support negative look-behind, I suggest using an expression like this one /([^="'])?\#(\w+)( .*)?/ And adjusting a couple of things in the selection logic.

patrick-steele-idem commented 8 years ago

Thanks for the fix @merwan7 !. New version published: marko-widgets@5.3.5

I did make one small tweak to not use a capturing group: https://github.com/marko-js/marko-widgets/commit/ea7b0bdaa506be93c87099b23f779596ccb9d410