knockout/knockout — pull request #653 by mbest (2013-09-13 21:07:20+00:00)
Title: optionsCaption using setHtml() instead of setTextContent()

The optionsCaption binding should set the text content of the option element, rather than setting child html. If it set optionsCaption: '', I get no text for the undefined option in most browsers due to invalid markup.

[The html option element has a text content model](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-option-element). This means that it cannot have child elements, and therefore there is no reason to support optionsCaption with actual html. This means that correctly using optionsCaption today requires html escaping of the input before passing it in.

The code fix is simple, though I realize there may be issues with fixing this breaking "bug-compatibility" in the case where people have already done html escaping to work around this.

At line 2284 (in my 2.1.0-debug.js)
```javascript
if (allBindings['optionsCaption']) {
var option = document.createElement("option");
ko.utils.setHtml(option, allBindings['optionsCaption']);
ko.selectExtensions.writeValue(option, undefined);
element.appendChild(option);
}
```
The line:
```javascript
ko.utils.setHtml(option, allBindings['optionsCaption']);
```

should be replaced with:
```javascript
ko.utils.setTextContent(option, allBindings['optionsCaption']);
```