On 10/5/06, Bob Ippolito <[EMAIL PROTECTED]> wrote: > Yes absolutely. I've wanted to add CSS selector support for a long > time, but I haven't had the opportunity to do it. There's even an open > ticket on the issue.
Hi all, I gave this a stab. I ported selector.js from prototype to MochiKit, in a module called Selector. It supports getting elements by tag, class, id and all CSS3 attribute selectors (=, ~=, ^=, $=, *= and |=). The prototype version didn't support ^= or $= but they were easy to add. Also, prototype had the non-standard != which could be useful in some cases. It supports sub-element selecting (like "div#form input") but not other combinators (E > F, E+ F, E~ F) - although I think they could be added. It doesn't support any pseudo-classes. Bob, I couldn't find the ticket - I was going to attach the files there. I'm attaching here instead. There are no unit tests, but test.html has a demo - works in IE 6, FF 1.5 and Opera 8.54. Arnar ps. the main function to call is MochiKit.Selector.findChildElements - but a la prototype I defined the $$ function that calls findChildElements on the document. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit -~----------~----~----~----~------~----~------~--~---Title: untitled
Demo
Test originally from this blog entry.
Here are some links in a normal paragraph: Google, Google Groups. This link has class="blog"
: diveintomark
Everything inside the red border is inside a div with id="foo"
.
This is a normal link: Yahoo
This link has class="blog"
: Simon Willison's Weblog
Nonninn
Sniðugt
Selector.js
Description: JavaScript source