This is my first shot at a JavaScript library, it includes support for:
CSS1 Selectors (By tag name, class name, ID, and parent node trees, although that's a bit different)
CSS3 Pseudo-classes
Multi-element CSS changes
Animation (multiple elements, too!)
Additional extensions
The CSS1 selectors are a bit different when dealing with ancestor-of selectors. Normally, in CSS, "div p" would be any <p> element under a <div> element. In Syntactic Sugar, it must be a direct child (equivalent to "div > p" in CSS). This is because I found it too complicated and unnecessary to include the relationship selectors (*: general sibling, >: direct child, <: direct parent, ~: general sibling, +: adjacent sibling). If you find it necessary, let me know - I'll move it up on the priority list. I'm working on it.
Here's a syntax example. It takes all <div> elements that are the last <div> element in their parent element that also have the class "blue" but not the class "dontstyle" and colors them blue and italicizes them:
One known bug is that the nth-child, nth-last-child, nth-of-type, and nth-last-of-type selectors do not work with expressions, such as ":nth-last-child(2n+3)". Once again, working on it.
Please enjoy this library and let me know about any bugs, or any features you want added. Attached are the main library, the animation extensions, and an example HTML file. The example HTML is example.txt (VBForums doesn't let you upload HTML files directly) and contains both scripts so people who just want to see what it's like don't have to download a whole ZIP file.
Last edited by minitech; Feb 21st, 2011 at 04:34 PM.
I just took quick look inside the code and didn't yet tested it, it will be nice to if you'll post here more examples of how to use it and what your library can do.
one thing though, why you are re-building the css selecter system? you can add sizzle selector system and focus in developing new features that users can't find in other libraries. even John Resig the creator of jQuery did it.
Anyway I'm really impressed, keep up the good work.
Thanks I have a little policy, though - I never, ever use libraries of code that aren't mine unless it's really something I can't make. That way I always learn something from making it, and I can customize it very easily.
Thanks for the suggestions, I'll add some more examples.