vdw / HideSeek

A simple, mobile-friendly, yet customizable quick/live search jQuery plugin.
http://vdw.github.io/HideSeek
Apache License 2.0
429 stars 74 forks source link

Search for attribute fails on elements missing the parameter #23

Closed andys8 closed 8 years ago

andys8 commented 8 years ago

Setting parameter attribute to title or alt fails when there are elements with without the parameter.

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

Cause should be this line: https://github.com/vdw/HideSeek/blob/master/jquery.hideseek.js#L82

vdw commented 8 years ago

Hi,

just to note that by setting a custom attribute to configuration means that the html structure complies with that attribute, meaning if your custom attribute is the "alt" then the list items should have that attribute, otherwise the html structure is invalid.

Also, HideSeek can handle, without errors the empty attributes, but not the missing ones.

Anyway, I would really like to merge your request if you explain to me the situation where you have list items without the required attributes in order to evaluate the need of that request.

Thank you, d

andys8 commented 8 years ago

Hi Dimitris,

my short answer is: The search shouldn't break on missing optional arguments.

What I have in mind searching a whole document with different structure for sparse set values. Even if that is not the point of the library it's working great with text. I think the search wouldn't work with all children with the alt-attribute either but that's another point. Even if your example is a well ordered list I wouldn't force the user to set empty values if there are only 5 of 1000 items with value.

On the other side I see your point with the structure having to fit the config. Even if I prefer to make the search more robust, I would throw more meaningful error messages in this case.

Have a nice day ;)

vdw commented 8 years ago

Hello Andy,

I understand that you have data that you can not "control", but generally speaking, as long as you are using a plugin, library or even a framework I believe that you have to conform to the requirements otherwise you get an error or wrong results (the error is preferable).

Anyway, your pull request is welcome and merged.

Thank you for your contribution, d