Skip to content
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

Nested slot creates fallback even with override #639

Open
StrahilKazlachev opened this issue Sep 4, 2018 · 0 comments
Open

Nested slot creates fallback even with override #639

StrahilKazlachev opened this issue Sep 4, 2018 · 0 comments

Comments

@StrahilKazlachev
Copy link
Contributor

StrahilKazlachev commented Sep 4, 2018

I'm submitting a bug report

  • Library Version:
    1.8.2

  • Browser:
    all

  • Language:
    all

Current behavior:
If we have nested slots the fallback content, for the nested one, gets created(ShadowSlot.prototype.renderFallbackContent gets called) even when there is an override provided for that slot. After that the fallback view is bound and unbound, it is never attached.

Expected/desired behavior:

  • What is the expected behavior?
    Repro - I'm expecting that when I have nested <slot>s and target the nested one, its fallback content is not created, as is the case with unnested <slot>s.

  • What is the motivation / use case for changing the behavior?

  1. Unnecessary processing(bind/unbind) and allocation of resources since <slot>s are static, so the created fallback View will never be used.
  2. In certain cases, when we have custom elements/attributes in the nested slot fallback, the unexpected binding/unbinding of the fallback View can lead to errors since unexpected(incorrect) data will get bound to them.

Observation
For nested slots with override for the nested one, it seems that when ShadowSlot.prototype.renderFallbackContent is called for the nested <slot>, it is done based on needsFallbackRendering evaluating to true because:

  • at this time projections is still 0(for the nested one)
  • the call to ShadowDOM.distributeView => ShadowDOM.distributeNodes, which will modify projections correctly is still to happen
  • the call to ShadowDOM.distributeView is done during binding of the View
StrahilKazlachev added a commit to StrahilKazlachev/templating that referenced this issue Sep 6, 2018
let ShadowSlot and PassThroughSlot handle nodes/view distribution themselves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants