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
Make Shadow DOM optional for components with slots #654
Comments
This is a very good argument to bring back non-shadowdom slot implementation from vcurrent. |
With shadydom polyfill you can force the polyfill to override native behavior, so you'll keep your styles.
v1 slot emulation is quite a lot of code, so v1 is as much a polyfill in that sense as any other polyfill. Shadydom is just a separate install so it doesn't "feel" like "installing aurelia"
Let me give you some arguments against it:
Installing the polyfill is something we could make a bit easier, perhaps with a Seems like a relatively small price to pay (an extra dependency in your tree) to save an enormous expense (redoing slot emulation). Besides, in most cases you can use replaceable instead of slots to do the same thing, and probably should. Given all of the above, I firmly vote against, but I welcome counter-arguments. |
I think there's one thing we could do. We've discussed supporting emulation of default slot content only as something that might be not too much work. When you get into named slots and various types of slot to slot project, it get's very complicated. So, we could do something like this:
But I think with the above and the polyfill, we can match v1 while also providing a way forward for those of us that want to just use shadow dom. Even if we can't achieve item 2, the pollyfill will handle that for us as well. So, we can save item 2 for later if we work out the rest (which should be relatively trivial). Of course, this needs to be documented. I've got a placeholder article dedicated to styling components that is intended to go over most of this. |
Thank you for sharing your reasons and considerations. I fully agree that bringing back v1-behavior might not be a good trade-off.
There are use-cases where this is not equivalent. (Apart from creating more boilerplate and adding complexity to every usage site due to the scope-change inside the template element. I’ve worked around the Shadow DOM in v2 for now by converting the I think adding I’m not so sure about item 5. If Aurelia has no external dependencies yet, I wouldn’t break that pattern for this feature. I think having |
I understand. It's 14 characters vs 34 characters, which is a huge difference in small pieces of template. <template replaceable></template> <slot></slot> What @EisenbergEffect 's plans seem to boil down to is making slots like a shortcut for replaceable, and without the context targeting. |
@fkleuver You misunderstood me. I meant what it does to the usage site not the component’s template. <tag>Innercontent with ${interpolation}</tag> vs. <tag context.bind="interpolation"><template replace-part="content">Innercontent with ${context}</tag> (And it gets worse if the context parameter requires multiple unrelated properties) |
@rluba We can easily add a nice shortcut for that though. For example, placing So custom element template: <div replaceable></div> With custom element declaration: <tag replace-part>Innercontent with ${interpolation}</tag> Would yield: <tag>Innercontent with ${interpolation}</tag> |
Random thought. |
|
Yeah that's the only functional difference between replaceable and slots in that sense. You get the context targeting. We could make that configurable though via an alias I suppose. Then we'll more or less have v1-like slot emulation. |
@fkleuver Slots and replacelables are not quite the same because of this: component-one.html<div>
<slot></slot>
</div> component-two.html<component-one>
<slot></slot>
</component-one> my-app.html<component-two>
Content here...
</component-two> In the end the content gets projected into the slot in component one. This is what I meant above when I said "...we need to keep projecting the content down until it bottoms out." It's hard to explain but hopefully the example above makes it clearer. At first I wasn't a fan of an |
If we decide to support both, can they both be For me there is high-cognitive cost of having two different elements that do very similar things (footgun?). I feel like it fits better as an option within one element (whatever the name). |
My concern with using Anyone else have opinions? I think I could be convinced either way. |
I’m with @EisenbergEffect here. Using Regarding the name: "inline" is a very overloaded word and I wouldn’t understand which meaning really applies in this context. I think You could call it |
Good point. Also, |
Actually we could also support the other way around to smooth user experience. Users just use
Our conventions plugin can rewrite |
@3cp That makes me a bit uncomfortable as it muddies what is standard and what is aurelia-specific. I'm not sure there's a ton of value in that, because in practice, one doesn't simply turn on shadow dom :) You generally have to re-work your CSS as well, which could be a large task. So, I think the work involved in changing a slot definition is trivial compared to the CSS re-work. |
Nvm, I doubted myself if this is a bad idea. :) |
Any plan for this before alpha release? |
The PR for Closing this in favor of |
🙋 Feature Request
I’ve tried to convert one of our internal apps to vNext in the past few days. One thing that causes problems for us is that components with
<slot>
s now use the Shadow DOM, which…🤔 Expected Behavior
I’d be really great if the Shadow DOM was Opt-In. Especially because it has other side-effects like #653. Slots worked great in Aurelia v1 without the Shadow DOM (although I expect this was a lot of work…)
🔦 Context
The
<slot>
of Aurelia v1 was a perfect equivalent of AngularJS’s<transclude>
. They filled an important role without causing all the trouble that the Shadow DOM does – in a homogenous environment.I do understand that the Shadow DOM might be useful for heterogenous environments (i.e. an Aurelia component inside a CMS). But for "Aurelia owns the whole page" scenarios, its benefits are dwarfed by its side-effects.
The text was updated successfully, but these errors were encountered: