Skip to content

Instantly share code, notes, and snippets.

@paton
Last active May 24, 2016 22:02
Show Gist options
  • Save paton/019be9913a7b3aa70dbde98459563829 to your computer and use it in GitHub Desktop.
Save paton/019be9913a7b3aa70dbde98459563829 to your computer and use it in GitHub Desktop.
window.document.normalize() breaks Knockout 3.3.0
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script>
<script>
// Problem occurs on IE 11 on Windows 10 (and earlier versions)
// Problem does NOT occur in Chrome
// window.document.normalize(); breaks knockoutjs bindings
// Upgrading to Knockout 3.4.0 fixes the problem
$(function () {
var view = {
list: ko.observableArray([{ item: 'Dog' }, { item: 'Cat' }])
};
ko.applyBindings(view, document.getElementById('list'));
window.document.normalize(); // This line breaks the knockout bindings
setTimeout(function() {
view.list([]);
view.list.push({ item: 'Person' });
// Should: update table with just "Person"
// Observed: Table updates to "Person" and "Dog", but "Cat" is removed
}, 1000);
});
</script>
</head>
<body>
<div data-bind="foreach: list" id="list">
<div data-bind="text: item"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment