2009/4/23 HissingInfernoOfAudio <rono.mu...@gmail.com>: > > Hi, > I've stumbled onto the case in which we want to perform a selector > find on an element with a period in its id: > $('my_mail_google.com').down('img') > and the result is null, since Selector.findElements alters the > selector for the selector API by inserting > # and the id into the selector, resulting in the new selector: > '#my_mail_google.com img' > which of course looks for an img element under an element with id > 'my_mail_google' and class 'com'. > > In short, findElements is missing an escaping for the id. Here's a > revised code: > findElements: function(root) { > root = root || document; > var e = this.expression, results; > > switch (this.mode) { > case 'selectorsAPI': > // querySelectorAll queries document-wide, then filters to > descendants > // of the context element. That's not what we want. > // Add an explicit context to the selector if necessary. > if (root !== document) { > var oldId = root.id, id = $(root).identify(); > e = "#" + id.replace(/\./, '\\.') + " " + e; > } > > results = $A(root.querySelectorAll(e)).map(Element.extend); > root.id = oldId; > > return results; > case 'xpath': > return document._getElementsByXPath(this.xpath, root); > default: > return this.matcher(root); > } > }, > > > Thanks! > > >
Interesting. Initially, I thought you can't have a . in an ID, but http://dev.w3.org/html5/spec/Overview.html#the-id-attribute says only spaces are disallowed. The issue is how would $$('#mail.com') differentiate between ... <span id="mail" class="com"> and <span id="mail.com"> No matter how you fiddle with the selector, the "." gets in the way. If possible, I would change my id's and classes to only use the _ symbol as this symbol is of no importance in any of the languages (well, except as a single character in SQL's LIKE syntax). -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---