Check on end comment too strict

231 views
Skip to first unread message

Michiel Pauly

unread,
Jul 8, 2020, 4:49:59 AM7/8/20
to KnockoutJS
When upgrading to a newer version (from 3.2.x to 3.5.x) a new check has been introduced on matching end comment. The check is super! But it now throws an exception.

That is a little bit too much. Why not log the error in the console?

When knockout is used in a (relative) complex environment where a lot of templates are used and even code is dynamically put in through SQL it is very hard to catch all errors at once. Especially if the software is used at various servers and each server has the same software set but its own content.

The exception makes it almost impossible to switch to the newer version. But if an error is logged to the console, you still get notified of the error (which is great) but it is still backwards compatible.

Suggestion (in v3.5.1 line 3098), change
if (isUnmatchedEndComment(node.nextSibling)) {
                               
throw Error("Found end comment without a matching opening comment, as child of " + node);
                           
} else {
                               
return null;
                           
}

to

if (isUnmatchedEndComment(node.nextSibling)) {
                                console
.error("Found end comment without a matching opening comment, as child of " + node);
                           
}
                           
return null;


With kind regards

Michael Best

unread,
Jul 21, 2020, 12:09:47 PM7/21/20
to KnockoutJS
Good points. Can you open an issue or PR in Github?

Michiel Pauly

unread,
Jul 28, 2020, 12:50:05 PM7/28/20
to KnockoutJS
Would love to, but don't know how. ;-)

Jonathan Carter

unread,
Jul 28, 2020, 1:10:56 PM7/28/20
to KnockoutJS
Reply all
Reply to author
Forward
0 new messages