Attribute selectors probably should use quotes around the attribute value
nateweiss opened this issue · 1 comments
Hi,
First, thanks for this library. I noticed that if you're using the optional 'attribute' selector style, the resulting selector is not quoted, which can lead to some errors if it decides to write a selector such as a[href=some-page.htm]
or similar.
I've added a modification locally that just adds quotes (so a[href="some-page.htm"]
or whatever), would you like a Pull Request with that change?
Related, I've also added an attribute_blacklist
(defaults to ['id', 'class']
) and attribute_whitelist option
(defaults to []
) option, at the same level as the existing selectors
option. Basically, my use case wants to "prefer" selectors that are based on link targets, so now my usage is like:
new CssSelectorGenerator
selectors: ['id', 'class', 'attribute', 'tag', 'nthchild']
attribute_whitelist: ['href','src']
I've also added a class_blacklist
option (defaults to []
), if there are CSS class names that shouldn't be considered by getClassSelectors
. In my case there are a handful of "internal" class names that should be ignored when generating a selector.
Let me know if you'd like PRs for any of these changes. They are all pretty trivial in terms of the actual code changes.
Thanks, I have merged the changes.