Jerry hasClass() question

16 views
Skip to first unread message

Alex Smirnoff

unread,
Feb 9, 2015, 12:52:54 PM2/9/15
to jod...@googlegroups.com
Hello,

First, thank you for the Jodd (for now I am using Jerry). Great thing for implementing HTML parsers.

I'm using latest (3.6.4 for now) and have a question.

Is there a particular reason for using fromCamelCase() inside addClass(), hasClass() etc functions? 

I have a HTML which contains, for instance, the element with ' class="theDay" '. 

As far as I know, all cases are allowed in both HTML 4 and 5.

I can not check if the particular element contains class "theDay" or not, because hasClass() converts my HTML class name (which is function param) to 'the-day' BUT it does nothing to the node element class so I have the situation

1. I ask if element contains 'theDay' class.
2. hasClass() converts my argument to 'the-day'
3. hasClass() compares converted 'the-day' to the original 'theDay' from node;
4. I have false in return but should have 'true'

Maybe I should use some special DOCTYPE so DOMBuilder convert all classes inside nodes from camel case (then hasClass() will compare correct class names)?
Also, as soon as hasClass() uses protected finalinternal nodes I can not just create a workaround with my custom class as well as I can not extend Jerry class (which returns objects of Jerry type) or write a decorator for it. 

Could you please let me know what is the purpose of fromCamelCase() and should I do something to make it work? 

Thank you.

jodder

unread,
Feb 9, 2015, 7:32:08 PM2/9/15
to jod...@googlegroups.com
Hey Alex,

glad to hear that Jerry works for you - at least, most of the time :)))

What you are asking is a great question... it is a small bug; let me explain:

jQuery.css() does the conversion -> as it works with style names (but not classes!) And thats why I have probably continued with the class-related methods. So this is wrong. css() should stay the same, but classes methods should not do the conversion, as you said!

I will commit the change ASAP, so you can build it and continue using it.

Yeah, this kind of issue is hard to fix using just OO. You should be able to extend Jerry class, afaik, but doubt that it would be helpful. Btw, if you have an idea how to 'loose' the Jerry let me know ;)))

Thank you for your time! Stay tuned, the commit will come soon !

Alex Smirnoff

unread,
Feb 10, 2015, 7:34:17 AM2/10/15
to jod...@googlegroups.com
Hi Igor,

Thank you for your message and for your commit, everything works great.


Reply all
Reply to author
Forward
0 new messages