Hacker News new | past | comments | ask | show | jobs | submit login




You don't have to use the .write method. The way enyo 1.0 works and the way that's still supported is to use .renderInto(domNode) to replace the innerHtml of a node with the new content. This is especially useful from the console, since writes don't work there.


I imagine it makes the API easier for non-JS developers. Considering its origins as a purely client-side library it does makes sense, as there would be no need to worry about moving script tags down the page to speed up execution.

Technically, you could probably replace the document.write with something like:

   var scripts = document.getElementsByTagName('script');
   var current = scripts[scripts.length - 1];
   var temp = document.createElementNode('div');
   temp.innerHTML = this.generateHTML();
   current.parentNode.insertBefore(temp, current);
I wrote a script that hijacks document.write calls a little while back (https://github.com/joshduck/Injector.js) which lets you inject arbitrary HTML into your document and then execute inline scripts (including document.write) at a later time.


Can you explain why this is a bad thing?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: