#497 ✓ invalid
Anton

prototype v.1.6.03: Element.select works wrong under safari and chrome

Reported by Anton | December 18th, 2008 @ 05:03 PM

Hi,

I have a problem with Element.select in my project under safari and chrome. The problem occurs in the findElements function in the following line

results = $A(root.querySelectorAll(e)).map(Element.extend);

if my id contains special characters e.g. ':' I get following error "Uncaught Error: SYNTAX_ERR: DOM Exception 12" in this line.

if I escaped id before e.g. write something like this: e = "#" + id.replace(':', '\:') + " " + e instead of e = "#" + id + " " + e; all works ...

example:

<div id="div1:div">
    <div>
        <span class="span">123</span>
    </div>
    <div>
        <span class="span">123</span>
    </div>
    <div>
        <span class="span">123</span>
    </div>
    <div>
        <span class="span">123</span>
    </div>
    <div>
        <span class="span">123</span>
    </div>
    <div>
        <span class="span">123</span>
    </div>
</div>

<script>alert(Element.select($('div1:div'), '.span').length);</script>

Comments and changes to this ticket

  • Juriy Zaytsev

    Juriy Zaytsev December 18th, 2008 @ 06:59 PM

    • State changed from “new” to “invalid”

    Escaped colon denotes namespace token, if i'm not mistaken.

    From the spec: "CSS selectors may be declared using an escaped colon "\:" to describe the fully qualified names, e.g. "html\:h1" will match <html:h1>"

    Webkit's querySelectorAll does not support namespaces and so rightfully throws an error : )

    Try [id="foo:bar"] as a workaround.

    Closing as invalid.

  • Anton

    Anton December 19th, 2008 @ 11:54 AM

    ok, thanks for quick response :),

    Let's look through my example again under Firefox and IE Element.Select returns spans with css class 'span', under the safari it doesn't do the same.

  • nbelaevski

    nbelaevski December 20th, 2008 @ 02:17 PM

    Hello Juriy,

    Ok, you may consider the patch invalid, but how can we make Element.select() work in Safari? The issue reproduces perfectly and your workaround does not seem acceptable for us. Please advice!

  • msznapka

    msznapka March 3rd, 2009 @ 12:11 PM

    Good news everyone! ;) With new prototype 1.6.0.4b the problem is fixed. Checkout my attachment.

  • Juriy Zaytsev

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Attachments

Pages