JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.debug.js"></script>
In IE8, running ko.toJSON will fail at a random point in time. Clicking the button will attempt to run it 200 times in a row. jsfiddle doesn't play nice with IE8 sometimes, but saving the frame with the button in it and then running it locally will show the same result.
<button id="btn">Click me to run</button>
<div id="output">
</div>
JavaScript
$(document).ready(function() {
$('#btn').click(function() { runMe(); });
});
var debug = function(message) {
$('#output').text(message);
};
var runMe = function() {
var i = 0;
try {
while (true) {
i++;
if (i > 200) {
debug('no errors');
break;
}
var container = new StrippedFormView(testingSerializedModel);
ko.toJSON(container);
}
} catch (e) {
debug("i have failed after " + i + " tries. " + e);
}
}
var testingSerializedModel = {
"pages": [{
"fields": [{}]
}]
};
var StrippedFormView = (function($) {
var view = function(args) {
var self = this;
self.pages = ko.observableArray();
if (args.pages) {
for (var i = 0; i < args.pages.length; i++) {
self.pages.push(new StrippedPageView(args.pages[i]));
}
}
};
view.prototype = {
'toJSON': function() {
var copy = ko.toJS(this);
return copy;
}
};
return view;
})();
var StrippedPageView = (function() {
var view = function(args) {
var self = this;
self.fields = ko.observableArray();
if (args.fields) {
for (var i = 0; i < args.fields.length; i++) {
var f = new StrippedFieldView(args.fields[i]);
f._page(self);
this.fields.push(f);
}
}
return this;
};
view.prototype = {
'toJSON': function() {
var copy = ko.toJS(this);
return copy;
}
};
return view;
})();
var StrippedFieldView = (function() {
var view = function() {
var self = this;
self._page = ko.observable();
return self;
};
view.prototype = {
'toJSON': function() {
var copy = ko.toJS(this);
copy.pageId =...