karax icon indicating copy to clipboard operation
karax copied to clipboard

No support for Shadow DOMs

Open Epictek opened this issue 5 years ago • 5 comments

This would be a useful feature for my current project.

Seems like a lot of changes would be required to support it though? For a start setRenderer would need to take an element rather than a string for the root dom and the KaraxInstance would also need to contain the rootElement.

I'm not sure what other changes would also need to be made but hopefully it can be done without breaking backwards compatibility.

Epictek avatar Oct 21 '18 23:10 Epictek

You need to elaborate on this feature request. It might be just what I've wanted to do for a couple of weeks now, though... :-)

Araq avatar Oct 22 '18 17:10 Araq

Well my use case is I want to render a karax vdom within a page inside of a shadow dom root.

Vue lets you do it using the following code

import Vue from 'vue';

const shadow = document.querySelector('#hostElement').shadowRoot;

new Vue({ el: shadow.querySelector('#app'), // ... })

Epictek avatar Oct 23 '18 10:10 Epictek

Also seems like shadow dom api needs to be added to the main nim js lib before this is possible.

Epictek avatar Oct 23 '18 10:10 Epictek

So... karax.setForeignNodeId()?

Araq avatar Oct 23 '18 11:10 Araq

We should revisit this now that https://github.com/nim-lang/Nim/pull/14979 was merged; I also am curious whether shadow dom could simplify some aspects of karax (including encapsulation of DOM and css)

some links:

  • https://medium.com/rate-engineering/winning-the-war-of-css-conflicts-through-the-shadow-dom-de6c797b5cba
  • https://stackoverflow.com/a/36906251/1426932

timotheecour avatar Oct 23 '20 11:10 timotheecour