Skip to content

[type="text"] selecting input elements with no type attribute #33

Closed
@jamietre

Description

The default value for "type" is "text" under HTML5, however, CSS selectors act against the HTML markup and not the value of the attribute. This was overzealously implemented in the last release and resulted in all input elements of type text (regardless of whether the attribute was present) being selected. Despite this being an intuitive and useful behavior, it's wrong and is not how browsers do it. Selecting on [type="text"] now correctly ignores input elements with no type attribute.

Note that in jQuery 1.8 the :text selector has been deprecated, leaving no way in the publically supported API to select all text input elements. That is, <input /> is a valid text input according to the HTML5 spec since "text" is the default for the type attribute. The jQuery :text pseudoclass selector does include this (as well as ones that included a type=text attribute), but is now officially deprecated.

I think this is a very useful selector, especially since CsQuery will often be used against HTML which someone else marked up and you don't have the luxury of making sure all your text inputs have a type attribute, so I have no intention of removing it from CsQuery.

Generally speaking since CsQuery does not have all the same goals as jQuery (e.g., small size) I doubt I'll make a habit of ever removing deprecated features, unless there is a conflict with a more current usage.

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions