-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable creating widgets in shadow DOM #517
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general feeling is that it makes Widget
even more complicated. And it will create confusion as the style sheet methods are not always available.
As nothing prevent a developer to set the widget node as a shadowRoot. I would prefer developer to go that path and knows explicitly that a particular Widget contains a shadowRoot.
To clarify, I would prefer developer to do:
const node = document.createElement('div');
const root = node.attachmentNode.attachShadow({mode: 'open'});
// populate `root` with the widget view
// ...
const w = new Widget({node});
// deal with local style sheet if needed
// ...
This is similar to wrapping a custom elements (= webcomponents).
const node = document.createElement('my-element');
const w = new Widget({node});
my-element
will contain a shadow DOM by definition.
There is an appeal of simplicity in what you propose, but there would be inconsistencies too, for example, Also, we would end up duplicating the code for managing adopted styles. The alternative could be to use the composition approach that you suggest in a new subclass say class ShadowDOMWidget extends Widget {
constructor(options: {node: Node}) {
const wrapper = document.createElement('div');
const root = wrapper.attachShadow({mode: 'open'});
super({...options, node: wrapper});
this._root = root;
}
adoptStyleSheet(sheet) {}
removeAdoptedStyleSheet(sheet) {}
} but then we cannot just make shadow DOM optional the same way as we do with |
Playing around with that example: https://mdn.github.io/web-components-examples/edit-word/ I added a class to the The all point of the shadow dom regarding styling is to add visibility of what can or cannot be styled. So I don't understand why breaking this by hooking style sheets.
|
I don't believe this is the case. In your example
I don't believe this to be the case. There is also a reason for why
What I set out to achieve is making stylesheets for specific components independent. For example, re-rendering menu styles should not need to match against 1000s of notebook-related styles rules. |
but I am happy to consider whether we should go all in (if it simplifies things and enables other things thanks to slots, etc), but that would likely be Lumino 3 given the timelines. |
Reporting it some notes of the performance meeting: Discussion around web components adoption in the future in lumino/lab ecosystem:
Mike also reported that the measured gains so far were not as impressive as with other performance improvements he did previously. So I would prefer adding an new |
In that case I am removing this PR from Lumino 2.0 milestone as I believe we can add |
Fixes #434.
Introduces a distinction between
attachmentNode
and a contentnode
.Adds new methods:
adoptStyleSheet()
removeAdoptedStyleSheet()