thoughtbot/capybara-webkit — pull request #269 by jasonmp85 (2012-02-12 16:21:57+00:00)
Title: Fix destructive select methods

Both `select_option` and `unselect_option` were modifying the `selected` attribute of their target `
` element. This attribute is meant to be used solely as the marker for which `
`(s) is (are) the default selection(s) in a (multi-)`` element. The actual _selectedness_ of an `
` should be tracked using its `selected` **property**. Read [the spec][] for more info.

This change removes any code which modified the `selected` attribute of `
` elements, which leaves only the code that modifies the `selected` property. In addition, `Node#value` needed to be changed to return `
` elements whose selectedness is true rather than just those with a `selected` attribute.

The capybara project proper walks over _all_ `
` elements and manually deselects those which are not the new selection. Reading the [spec for the select element][] reveals this is unnecessary:

> If the `multiple` attribute is absent and the element's display size is greater than 1, then the user agent should also allow the user to request that the `option` whose selectedness is true, if any, be unselected. Upon this request being conveyed to the user agent, and before the relevant user interaction event is queued (e.g. before the `click` event), the user agent must set the selectedness of that `option` element to false and then queue a task to fire a simple event that bubbles named `change` at the `select` element, using the user interaction task source as the task source.

Some failing test cases are introduced in the first commit; however, after the second commit all tests pass.

[the spec]: http://dev.w3.org/html5/spec/Overview.html#the-option-element
[spec for the select element]: http://dev.w3.org/html5/spec/Overview.html#the-select-element