SteveSanderson/knockout — Issue #307: Find <!-- ko --> elements within unclosed tags
Author: natevw
Created: 2012-02-03 00:22:20+00:00
State: open

When I omit [optional tags](http://www.w3.org/TR/html5/syntax.html#optional-tags) in my markup, it appears that Knockout has trouble with the scope of the special \ comments. This is likely because the comments end up tucked away in the DOM as the last node of the last nested child instead of as sibling nodes .

Would it be possible to handle the example below by virtually "pulling out" any ko-comments that are buried like this example?

Resource
Mon am
Mon pm
Tue am
Tue pm
Wed am
Wed pm
Thu am
Thu pm
Fri am
Fri pm

empty track

With this markup the following code causes a `Error: Cannot find closing comment tag to match: ko foreach: resources` error, even on trunk (not fixed alongside issue 212).

var viewModel = {
resources: [
{name:"Person 1", tracks:[{name:"Track 1"}]},
{name:"Person 2", tracks:[{name:"Track 1"}, {name:"Track 2"}]}
]
};
ko.applyBindings(viewModel);

The workaround is to add in close tags for elements that Knockout currently expects to be siblings of the comments.