tdumitrescu / virtual-jade

Compile Jade templates to Hyperscript for Virtual DOM libraries
Other
31 stars 4 forks source link

don't JSONify an object with toString() #35

Closed andrewpurcell closed 4 years ago

andrewpurcell commented 4 years ago

In some places, we rely on the toString behavior of objects passed as attrs. Check first for the function and if it's not defined, call JSON.stringify. This will break for inheritance hierarchies where toString is defined one or more levels above the instance but should work for our use cases.

andrewpurcell commented 4 years ago

decided to not add any magic for this and keep the contract simple: if you pass us an object, we'll JSON stringify it. if you want to do any other serialization, do it before you pass the string.