On May 15, 11:52 am, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> On Thu, May 15, 2008 at 1:19 PM, Byron Young <[EMAIL PROTECTED]> wrote:
> > I was just using 'attr' as an example meaning 'any attribute'.  The
> > one I actually ran into trouble with was 'show',
>
> Show is also a bad choice. Any short, single word is probably a bad choice.
>
> I use custom attributes quite frequently, but they are always multiple
> words separated by an underscore or dash, also, to access the
> attribute value I *always* use
> $('my-element').getAttribute('whatever-attribute') as opposed to just
> $('my-element).whatever-attribute (which wouldn't work anyway).

I liked your suggestion of using a dash in the attribute name, so I
changed my attributes to 'show-container' and 'container-name', which
will avoid the problem of matching on an object method.

However, this caused the $(form).select('[show-container]') selector
to throw an error in FF.  Prototype didn't like me using a dash, and
instead of using the 'attrPresence' xpath selector it used 'attr',
because the 'attrPresence' pattern didn't include a dash but the
'attr' pattern did.

Here's a patch that fixes it for me (against the 1.6.0 release):

Index: prototype.js
===================================================================
--- prototype.js        (revision 11904)
+++ prototype.js        (working copy)
@@ -2962,7 +2962,7 @@
     id:           /^#([\w\-\*]+)(\b|$)/,
     className:    /^\.([\w\-\*]+)(\b|$)/,
     pseudo:       /^:((first|last|nth|nth-last|only)(-child|-of-type)|
empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,
-    attrPresence: /^\[([\w]+)\]/,
+    attrPresence: /^\[([\w-]+)\]/,
     attr:         /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])
([^\4]*?)\4|([^'"][^\]]*?)))?\]/
   },


byron
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to