ultraq / thymeleafjs

A basic implementation of the Thymeleaf templating engine in JavaScript
Apache License 2.0
52 stars 9 forks source link

Virtual DOM #28

Open ultraq opened 5 years ago

ultraq commented 5 years ago

As of writing, Thymeleaf and its processors are implemented to work on the DOM, hence the dependency on libs like JSDOM when running in a Node/server environment. Would it be worth it to do like other popular libraries out there and operate instead on a virtual DOM so that things like VDOM diffing can be done, splitting out the renderer into a different part of Thymeleaf?

It might make working on/with processors a lot easier as devs are manipulating plain JS objects, and removes the need for a big lib like JSDOM and having the wait for it to implement the bits of the DOM that I use in processors.

🤔

ultraq commented 5 years ago

Another thing I found which might be good to do this: processing templates as document fragments still gets the browser to operate on them. eg: I had a template where I had <img src="(some file that works as a static prototype"... and I'd notice 404s in the network tab as the browser tried to fetch those resources even though it wasn't part of the document.

ultraq commented 5 years ago

The browsers XML deserializer also has issues with self-closing `th:block: elements, throwing the whole parsing structure out. This'll need an HTML parser, cripes. Should be simpler than putting together the expression parser though!