Closed trescenzi closed 6 years ago
what is your use case ? I have a little poly for attachShadow, if I add iframe and a couple of accessors it might work already: https://github.com/WebReflection/attachshadow
Yet, I am not sure I understand what's the benefit of having something impossible to represent as string within the scope of basicHTML.
Thanks for extra clarifications.
Also important:
making it fully spec compliant
nothing in this project is aiming at being full spec compliant, there are other projects for that, as stated in the readme. I am not re-implementing WebIDL here, I am offering a lightweight layer to serve HTML from either NodeJS or Web/Service Workers, with the ability to define Custom Elements for NativeScript and other platforms that have nothing to do with WebIDL and the real DOM.
Cool yea I agree with your second comment. I wasn't 100% sure what the goal was though.
I'm mostly trying to get a very simply way to test web components at a high level in jest. Since jsDOM doesn't support custom elements I've fallen back on trying to get something else working haha. Right now I'm literally just defining it in the simplest way possible:
Object.defineProperty(window.HTMLElement.prototype, 'attachShadow', {
value: function() {
this.shadowRoot = this;
}
});
That's probably too dumb an implementation but it's working for now. Mostly my goal is to just have it render my components and then be able to check that different inputs give the correct outputs. So it being spec compliant isn't necessary. More that I just want to be able to append children to a this.shadowRoot
and call this.attachShadow
.
I'm not 100% sure your goal with basicHTML hence the question. If this is out of the scope of the project then I totally understand just closing this issue.
Thanks!
this.shadowRoot = this
as quirky as it looks, it might make sense. I will need to parse the options
object too and its mode
though, will implement something like that soon.
so, 0.16
has a very basic attachShadow
fake utility.
Awesome thank you for this!
Since basicHTML supports a
customElements
registry it might make sense for it to implement Shadow DOM as well.Simply implementing
HTMLElement.attachShadow
wouldn't be too tough for a first pass but making it fully spec compliant might be a more work.What are your thoughts on this?