yandeu / five-server-vscode

⚡ VSCode Extension for Five Server.
https://marketplace.visualstudio.com/items?itemName=yandeu.five-server
Other
120 stars 9 forks source link

injectBody removes body classes #8

Closed viveksjain closed 2 years ago

viveksjain commented 2 years ago

Hot reload with injectBody looks awesome, however, it seems to clear the class attribute on body which messes up some of the formatting on my HTML.

yandeu commented 2 years ago

Does it remove the classes?

Maybe it's just the popup messages messing up the format? They get appended to the Body element.

viveksjain commented 2 years ago

Yup, I definitely see it removing the classes. Should be pretty straightforward to repro but let me know if I should provide an example.

yandeu commented 2 years ago

It's probably just https://github.com/yandeu/five-server/blob/2fb91e2a55a72c67e49b5f9f3f0ad7fc022a8da5/client/injected.ts#L199.

I will check it soon 👍🏻

viveksjain commented 2 years ago

Thanks so much for the quick fix! I took a quick look at the code, looks like you already have the object newBody, can that be used directly for diff? Fixing id and class is good enough for me but technically it still doesn't handle some attributes.

yandeu commented 2 years ago

I can't remember why I used tmp instead of newBody for diffing.

I believe domParser is just there to throw an error if d is invalid.