This project is archived and is in readonly mode.

#1013 ✓resolved
Tim Wienk

document.id and funny characters in the ID

Reported by Tim Wienk | September 21st, 2010 @ 04:11 PM | in 1.3.0 rc2 (closed)

According to the HTML5 spec, IDs can contain anything but spaces now. The current document.id implementation doesn't take that into account:

Expected behaviour:

document.id('a.b') implies that the string that is passed is nothing other than an ID. So it should find an element with id="a.b".

Current behaviour:

document.id('a.b') passes the selector to slick as #a.b. Which parses that to an ID and a ClassName.

Fix:

Throw replace(/(\W)/g, '\\$1') at the string that is passed to document.id.

Extra info:

  • http://www.w3.org/TR/html5/elements.html#the-id-attribute
  • document.getElementById does find the elements
  • it works in 1.2.4.
  • in CSS characters are escapeable: #a\.b, so for getElements and $$ we're good. You just have to keep in mind that you have to escape \ the \\ to not parse the \.: $$('#a\\.b'). (That may be good to mention in the docs.)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Referenced by

Pages