plentico / pico

Svelte-like reactive UI compiler written in Go
2 stars 0 forks source link

Support <!DOCTYPE html> #9

Open jimafisk opened 2 years ago

jimafisk commented 2 years ago

The <!DOCTYPE> prototype is DocumentTypePrototype and a regular element is ElementPrototype.

For example a <div> is ElementPrototype > HTMLElementPrototype > HTMLDivElementPrototype.

So if you're hydrating at the top level of the document, you need to account for this since you can't create <!DOCTYPE html> like a regular element.

Creating regular html element in JS ```js document.createElement("div"); ```
Creating !DOCTYPE in JS ```js document.implementation.createDocumentType('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdd'); ```

There's a discussion with more details regarding the challenges of hydrating <!DOCTYPE> in Svelte here: https://github.com/plentico/plenti/issues/91