Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed two specs that were giving false negatives on IE<9.

  • Loading branch information...
commit df9acea5ff1bc91926988d867ba1d7f382634066 1 parent fca15fd
@SteveSanderson SteveSanderson authored
Showing with 30 additions and 5 deletions.
  1. +24 −2 spec/defaultBindingsBehaviors.js
  2. +6 −3 spec/runner.html
View
26 spec/defaultBindingsBehaviors.js
@@ -1471,8 +1471,30 @@ describe('Binding: Foreach', {
'Should be able to nest containerless templates directly inside UL elements, even on IE < 8 with its bizarre HTML parsing/formatting' : function() {
// Represents https://github.com/SteveSanderson/knockout/issues/212
- // Note that the </li> tags are omitted, to simulate IE<9's weird parsing, hence the <!-- /ko --> tags are moved into the <li>
- ko.utils.setHtml(testNode, "<ul><!-- ko foreach: ['A', 'B'] --><!-- ko if: $data == 'B' --><li data-bind='text: $data'><!-- /ko --><!-- /ko --></ul>");
+ // This test starts with the following DOM structure:
+ // <ul>
+ // <!-- ko foreach: ['A', 'B'] -->
+ // <!-- ko if: $data == 'B' -->
+ // <li data-bind='text: $data'>
+ // <!-- /ko -->
+ // <!-- /ko -->
+ // </li>
+ // </ul>
+ // Note that:
+ // 1. The closing comments are inside the <li> to simulate IE<8's weird parsing
+ // 2. We have to build this with manual DOM operations, otherwise IE<8 will deform it in a different weird way
+ // It would be a more authentic test if we could set up the scenario using .innerHTML and then let the browser do whatever parsing it does normally,
+ // but unfortunately IE varies its weirdness according to whether it's really parsing an HTML doc, or whether you're using .innerHTML.
+
+ testNode.innerHTML = "";
+ testNode.appendChild(document.createElement("ul"));
+ testNode.firstChild.appendChild(document.createComment("ko foreach: ['A', 'B']"));
+ testNode.firstChild.appendChild(document.createComment("ko if: $data == 'B'"));
+ testNode.firstChild.appendChild(document.createElement("li"));
+ testNode.firstChild.lastChild.setAttribute("data-bind", "text: $data");
+ testNode.firstChild.lastChild.appendChild(document.createComment("/ko"));
+ testNode.firstChild.lastChild.appendChild(document.createComment("/ko"));
+
ko.applyBindings(null, testNode);
value_of(testNode).should_contain_text("B");
},
View
9 spec/runner.html
@@ -4,9 +4,12 @@
<title>JSSpec results</title>
<link rel="stylesheet" type="text/css" href="lib/JSSpec.css" />
- <!-- All specs should pass with or without jQuery being referenced -->
- <!-- <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script> -->
-
+ <!-- All specs should pass with or without jQuery+Modernizr being referenced -->
+ <!--
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
+ <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-1.7-development-only.js"></script>
+ -->
+
<script type="text/javascript" src="lib/innershiv.js"></script>
<script type="text/javascript" src="lib/diff_match_patch.js"></script>
<script type="text/javascript" src="lib/JSSpec.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.