Marko: renderToString is not implemented for the browser, but no error is thrown

Created on 6 Apr 2017  路  13Comments  路  Source: marko-js/marko

See: http://stackoverflow.com/questions/43202021/simple-client-side-rendering-not-working

We either need to implement this method or throw an error (and update the docs).

good first issue

Most helpful comment

Can I take this on ? I've got some free time these days and Im looking to get started around here.

All 13 comments

We should implement it. This would be a great first contribution for anyone looking to get involved.

Can I take this on ? I've got some free time these days and Im looking to get started around here.

@harrisjose Please feel free. Just try to follow the coding style and keep code fast and small. Here's where you will be making changes:

https://github.com/marko-js/marko/blob/430ce144ccf658d79cf1868cba5851f19c75d5d1/runtime/vdom/AsyncVDOMBuilder.js#L302-L304

Keep in mind that getNode() returns a DocumentFragment. DocumentFragment nodes do not support outerHTML which is why this is currently broken (marko used to return the first top-level HTML element node).

Also, test cases :)

Thanks in advance

Awesome! And don't hesitate to ask any questions. One of us will point you in the right direction 馃槃

Thanks for the pointers guys. Will hopefully get this done over the weekend :)

Okay so noob question, the only way to get the html out of a document fragment is by first appending it to a div and then getting its innerHTML right ? Is there any other way that I could be doing this ?

@harrisjose Yeah, that seems to be the case. Sorry for taking so long to reply. Is this something you're still working on/planning to work on?

Any progress on this yet? renderToString on the browser would be pretty nice to have.

@mlrawlings Im still interested to work on this. Although I kinda stopped looking into this because I never could decide if the method I suggested was the way to go forward.

@patrick-steele-idem @mlrawlings If the expected behaviour is to return the first top level element, we could just return the outerHtml from this.___getNode().firstChild. This works but I'm not sure this is the way forward.

Also, if I append the document fragment from ___getNode() to a dummy VElement I created using appendChild, and try to access the firstChild it should give me the first child of the document fragment right ? This does not seem to be happening. Any ideas ?

Hey @harrisjose, I went ahead and opened #734 because multiple people have asked about this. Feel free to check out the PR and give any feedback. Thanks!

Published [email protected].

Was this page helpful?
0 / 5 - 0 ratings