canjs / can-stache

Live binding handlebars templates
https://canjs.com/doc/can-stache.html
MIT License
10 stars 13 forks source link

Named Partials render with documentFragment in stringOnly state instead of expected string result #710

Closed JaneOri closed 5 years ago

JaneOri commented 5 years ago

I understand this may be marked as "won't fix" or at least probably isn't a priority since there are ways to work around it and most wouldn't ever need it. I took a few swings at fixing it but didn't get far in the time I have.

How often can you reproduce it?

Description:

Named partials (technically section renderer) produce document fragments even when stringOnly is true in the section its being rendered in (in a style tag, for example). https://github.com/canjs/can-stache/blob/b530682034cf1e59285046df5475b57ce5e5b0b1/src/mustache_core.js#L291 "res" is a documentFragment at that line when a named partial is rendered inside of style tag.

The text representation should be rendered instead.

Steps to reproduce:

https://codepen.io/anon/pen/eqRVZG?&editable=true&editors=0011

Expected results:

contents of style tag should be the raw text produced by the render. (Note: "innerHTML" of the fragment produced would be incorrect in the browser because it escapes things like ">" automatically)

Actual results:

contents of the style tag is "[object DocumentFragment]"

Environment:

Software Version
can-stache version latest
Browser chrome
Operating system windows 10

Thank you for your time! //James

justinbmeyer commented 5 years ago

This is a bug. Thanks for reporting!