knockout/knockout — pull request #844 by mbest (2013-11-27 23:38:21+00:00)
Title: IE7/8 issue with knockout 'text' binding in popup window

When I call ko.applyBindings against content of popup window, where presented at least one 'text' binding, I get the following error (only in IE7/8):
```javascript
SCRIPT16389: Unspecified error.
knockout-2.2.1.debug.js?_=1360769946967, line 191 symbol 21
```

See jsfiddle: http://jsfiddle.net/s7NAJ/2/ for the full source code and html.

Excerpt from knockout-2.2.1.debug.js where script fails (lines 187-193):
```javascript
setDomNodeChildren: function (domNode, childNodes) {
ko.utils.emptyDomNode(domNode);
if (childNodes) {
for (var i = 0, j = childNodes.length; i < j; i++)
domNode.appendChild(childNodes[i]); // this is line 191
}
},
```

As you can see knockout appends child element to domNode.
I think the problem is that `domNode.document != childNodes[0].ownerDocument`, so IE7/8 blocks this operation.
I think knockout should use checking here for this condition (IE7/8 only).

This code (lines 187-193) works correctly for parent window, where the same 'text' binding is presented.

For the sake of completeness, I put full source code below:
```javascript
window.entryP = function () {
(function () {
var head = document.getElementsByTagName('head')[0];

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
script.onreadystatechange = script.onload = function () {
if (!jQuery) return;
//jQuery.getScript('//cdnjs.cloudflare.com/ajax/libs/knockout/2.1.0/knockout-min.js', function () {
//jQuery.getScript('//ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js', function () {
jQuery.getScript('http://knockoutjs.com/downloads/knockout-2.2.1.debug.js', function () {
main();
});
};

head.appendChild(script);
})();

function ViewModel() {
var self = this;
self.caption = ko.observable('Title');
self.popup = function() {
popup();
};

function popup() {
var result = window.open('', 'win', getPopupSpecs());
popup = result;
popup.document.write(popupTmpl);
popup.document.close();
ko.applyBindings(self, popup.document.body);

function getPopupSpecs() {
var w = 400;
var h = 400;
var l = 10;
var t = 10;
return 'directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no, copyhistory=no, ' +
'left=' + l + ', top=' + t + ', width=' + w + ', height=' + h;
}
}
}

function main() {
var parentTmpl = jQuery(rootTmpl);
$(document.body).append(parentTmpl);

var vm = new ViewModel();
ko.applyBindings(vm, parentTmpl.get(0));
}

var rootTmpl = '\

\
\
\

\
';

var popupTmpl = '\
\
\

\
\

\

\

\
\
\

\

\
\
';
}
```