shama / base-element

:beginner: An element authoring library for creating standalone and performant elements.
81 stars 7 forks source link

[wip] base-element: add .toString() method #6

Closed yoshuawuyts closed 9 years ago

yoshuawuyts commented 9 years ago

wip. Closes https://github.com/shama/base-element/issues/5. Needs tests + docs added. Mostly checking if this is the correct interface. Thanks!

Changes

shama commented 9 years ago

Thanks! I tried this same thing yesterday and it causes a weird issue where this.element.toString() also called this.render() again for some reason. Simply renaming toString() to toHTML() fixed it but I wanted to find out why that was occurring.

shama commented 9 years ago

Dug into this a bit and it appears to be var document = require('global/document') which on the server shims min-document. Which in turn calls the toString() of the element itself thus creating an infinite loop. Still working on a fix...

shama commented 9 years ago

Merged with edits: https://github.com/shama/base-element/compare/04953ec953c407bafeaaeb2479ca951e70239556...aff848c0233e0436603b22f178a4aec9fa73571a Thanks!

yoshuawuyts commented 9 years ago

:tada: neat!