Knockout templating bug?

51 views
Skip to first unread message

Ralph Becket

unread,
Mar 29, 2015, 8:16:22 PM3/29/15
to knock...@googlegroups.com
I've just spent a merry few hours chasing down a bug which turned out to be an error in the HTML in one of my templates.  The symptom: Knockout was not rendering anything for this template, nor was it reporting any kind of error.

Here's a fiddle showing the problem: http://jsfiddle.net/ralphbecket/tx9zx3qt/

The console output is just [] -- the HTML error silently causes Knockout to drop the entire template markup.

I think this is a bug in Knockout.

Cheers,
Ralph

Gunnar Liljas

unread,
Mar 30, 2015, 1:36:18 AM3/30/15
to knock...@googlegroups.com
I disagree. KO can't be blamed when there are syntax errors in the code. Also, I think the browser is dropping the markup. Knockout will never know.

/g


Sent from Mailbox


--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ralph Becket

unread,
Mar 30, 2015, 2:00:47 AM3/30/15
to knock...@googlegroups.com
I traced the problem as far as ko.utils.parseHtmlFragment.  The template text passed in is definitely not empty.  I know it's very webbish for simple syntax errors to cause silent, mysterious failure, but in this case when the template text is non empty and the parsed HTML fragment is empty, then there's a good case to say an error has occurred.

Michael Best

unread,
Mar 31, 2015, 8:26:42 PM3/31/15
to knock...@googlegroups.com
I you also include jQuery, Knockout will use that for parsing the template. Otherwise, the Knockout built-in parser is pretty simple.

-- Michael
Reply all
Reply to author
Forward
0 new messages