-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
add .data() function. cleaned up PR #221 from @rafaelrinaldi, added tests, updated readme #264
Conversation
* @param {String} str String to be converted. | ||
* @return {String} String in camel case notation. | ||
*/ | ||
exports.toCamelCase = function(str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks a bit simpler: https://github.com/substack/camelize/blob/master/index.js#L12. not sure about correctness though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, substack's one is simpler and works just fine, cool.
Thank you for your feedback on this. |
@@ -23,6 +23,8 @@ var formatAttrs = function(attributes) { | |||
|
|||
// Loop through the attributes | |||
for (var key in attributes) { | |||
// Make sure it doesn't format data attributes. | |||
if (key.match('data-')) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also matches attributes like foo-data-bar
. key.substr(0,5)==="data-"
is what you want to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. Since this piece of code key.substr(0,5)==="data-"
is used in parse.js
as well as in render.js
, would you move it into utils.isDataAttribute() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my perspective, the inline variant is more readable and not significantly longer. ES6's String#startsWith
method will shorten this further as soon as it's enabled per default in node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the inline variant.
add .data() function. cleaned up PR #221 from @rafaelrinaldi, added tests, updated readme
thanks @andi-neck |
Thanks @matthewmueller and @andi-neck. I was finishing the college at the time so I didn't had much of it to spare on this 😔 Glad it make it to master! |
Since the .data() function was implemented by @rafaelrinaldi PR#221, but on an older version of cheerio, it didn't make it back into the original cheerio.
I couldn't wait for a solution on this, therefore I fixed this thing now.
I cleaned it up (with the up to date version), added tests and updated the readme.