reactql / kit

ReactQL starter kit (use the CLI)
https://reactql.org
229 stars 38 forks source link

Fix for #121 #122

Closed klarstrup closed 6 years ago

klarstrup commented 6 years ago

This is the proof of concept fix for #121

I want to collect some feedback with regards to the element id namespacing and the general approach to access these JSON blobs. document.getElementById().innerHTML is used here but there are many options to select them(ids, classes, data attributes).

I'd also like to talk about line 45 and its surroundings now, which is pretty dirty. Doing what is basically abstracted eval'ing(but I didn't want to include this change immediately):

(out += `window['${key}'] = JSON.parse(document.getElementById('${idPrefix}${key}').innerHTML);`)

My suggestion is to replace this script tag with another JSON blob containing our keys and moving all the window rehydration logic over into kit/entry/browser.js, check out my approach to that over at https://github.com/klarstrup/kit/compare/json-window...klarstrup:json-window-clean?expand=1 and tell me what you think.