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

Target element not being re-evaluated while the DOM is still being built #28

Open
Esger opened this issue May 13, 2024 · 2 comments
Open

Comments

@Esger
Copy link

Esger commented May 13, 2024

I'm submitting a bug report

  • Framework Version:
    1 - Aurelia CLI 3.0.1

  • Operating System:
    OSX 14.4.1

  • Node Version:
    18.17.1

  • NPM Version:
    9.6.7

  • Browser:
    all | Chrome XX

  • Language:
    ESNext

Current behavior:
Using the portal attribute, like portal="target.bind: isMobile ? '.bncHeader' : '.bncOptionsWrapper'" puts the element with this attribute at the end of the body if the intended target element isn't rendered yet. Otherwise it works fine.
I can work around this problem by binding the to-be-portalled element later, when the target element is available in the DOM but this is not ideal.

Expected/desired behavior:
The target portal element should be re-evaluated while the DOM is still being rendered.

What is the motivation / use case for changing the behavior?
For a hybrid application for desktop / mobile some elements need to be portalled to somewhere else on mobile.

@bigopon
Copy link
Collaborator

bigopon commented May 21, 2024

Thanks @Esger , it doesnt seem like a straight forward task with "while the dom still rendering". We can try to wait for the task queue probably, do you want to have a PR for this?

@Esger
Copy link
Author

Esger commented May 23, 2024

@bigopon Waiting for the task queue might be a better idea indeed. Our application makes several calls to the back end before everything is rendered.
Maybe the Mutation Observer API can be useful. https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver (observe the whole document to check if the target appears)
A PR for me isn't very useful I'm afraid :) although I am curious about the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants