Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is :text case sensitive?

Is the jQuery :text selector case sensitive?

For Example:

<input type="TEXT">

Does not match but:

<input type="text">

Does match.

This appears to be the case. I'm just looking for verification.

EDIT

It is looking like even the [type=text] selector is case sensitive in Chrome and Firefox but not IE8 (in IE8 document mode)

like image 349
Tom Hubbard Avatar asked Dec 12 '11 21:12

Tom Hubbard


1 Answers

Edit: despite my research I drew the completely wrong conclusion at first. Answer's been updated :O (kudo's go to @ThiagoSantos who had the correct answer from the start :D).

The jQuery ":text" documentation states:

Because :text is a jQuery extension and not part of the CSS specification, queries using :text cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method.

If you dive into the source of 1.7.1 it seems this selector is implemented as:

text: function( elem ) {
    var attr = elem.getAttribute( "type" ), type = elem.type;
    // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 
    // use getAttribute instead to test this case
    return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}

For <input type="tEXt" /> the value of attr turns out to be "tEXt", which won't match type. Much to my own surprise then:

The updated answer should be: :text is case sensitive

like image 82
Jeroen Avatar answered Oct 13 '22 00:10

Jeroen