Skip to content

Select value doesn't fallback to text content when value is undefined #633

@twolfson

Description

@twolfson

In browsers, el.value for an <option> will fallback from getAttribute('value') to the inner content of a node. Since jQuery executes in the browser, it gets this for free when it asks for el.value. However, Cheerio currently does not support this behavior. As a result:

<select><option selected>Hello</option></select>

$('select').val() will return [undefined] via Cheerio and ['Hello'] via jQuery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions