-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Promote {{-in-element}} to public API #287
Conversation
@cibernox are you aware of glimmerjs/glimmer-vm#619? |
@Turbo87 I knew it was public API in glimmer as it was mentioned in https://emberjs.com/blog/2017/10/10/glimmer-progress-report.html#toc_what-s-new-in-glimmer, but afaik it was not made public in Ember yet. |
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.
👌 I am in favor, thanks for putting this together!
I am in favor. It would be lovely to deprecate ember-wormhole, possibly preserving the name for a future generation of ember-wielding intergalactic travelers. 🚀 |
Could you point to any references to the existing private/intimate API for those of us who are not intimate with it yet so we can actually see what it is? :) |
@cibernox Thank you for putting this together! Can you expand the RFC a bit to not assume prior knowledge of the current private API?
The second point is especially important – enumerating the actual API surface helps avoid leaking "accidental" behavior into the public API, and also help reviewers identify potential problems. |
What about having a helper that targets named outlets instead? Ex: |
@Panman8201 One scenario that your idea doesn't cover, is rendering content from inside an Ember app to anywhere else in the page. Even somewhere that is outside the Ember app (sometimes the app is not the entire page but only a section inside a static page) |
7663a1c
to
64946b7
Compare
@chancancode I've added your suggestions. |
@cibernox looks great!
|
@chancancode I updated the doc
|
Like @chancancode, I am excited for this RFC. For future readers, I think something like ember-elsewhere is a better fit for rendering components with data from one part of an Ember app into another part of an Ember app. But there are plenty of cases (like the very common desire to render into Let me try to answer @chancancode's questions, but these are just my personal answers (don't treat them as authoritative if you disagree 😉).
I think this should assert in dev and fail silently in production. In general, the philosophy of Glimmer is to allow many dynamic questions to fail silently in production to keep apps running, while being very noisy in dev (and tests) to try to catch as many of these bugs as possible ahead of time. I also think this should assert for any value other than
I think we should disallow this until we have a separate RFC that covers how we should deal with foreign elements in general. Should the foreign context adopt the element? Would that cause other issues? How would either solution play with SVG?
There are two categories of "contexts" in HTML that are relevant to Glimmer:
Today, we are very careful about namespaces, so if you put a block with On the other hand, we do not (currently) reject stitching together content because the child content is not allowed by the HTML parser. In practice, this typically doesn't cause problems, with one major exception. In SSR mode, Glimmer serializes its DOM into HTML, which is then parsed on the client. If the parsing fails (for example, if a piece of content is ignored or moved), the behavior will differ between client-side rendering and SSR + rehydration. This is a real issue and one that we should address systemically, but I don't think we need to address it in this RFC to make progress. When we do address it, we will need to handle moving a
Teardown + rerender are today's semantics, and those semantics avoid thorny (design and implementation) issues that imo we shouldn't try to resolve today. I think the RFC should be explicit about today's semantics, including the execution of
I think we can get away with making it append-only for now (to avoid dealing with the cases you're describing). The only question is whether we want append vs. replace. For example, in the I think "replacing the entire content" is probably the majority use-case, so maybe what we want to do is make (in most cases, people could work around the nextSibling limitation by creating a wrapper element -- it's not usually good enough, but I suspect that for the use-cases targeted by this RFC, it would be managable for the time being).
We probably should have a formal description of this usual caveat. It amounts to a somewhat clear technical description around the details of bounds markers (and similar attribute concepts) in the Glimmer implementation, but we would want to turn those limitations into something understandable for humans. For this RFC, it's probably acceptable to gesture towards "similar limitations as manually mutating a component's DOM". |
The following is related, but probably should not prevent progress of this RFC. I have been playing with this a bit recently (see https://github.com/kaliber5/ember-in-element-polyfill), and what I find in particular difficult is to get this to work properly with FastBoot. The problem is that
So for this to become easily usable in FastBoot I think it would be useful to either
|
Another issue is that ember wormhole currently requires you to use renderInPlace in acceptance tests. Is it possible to come up with a way to fix this? |
@Gaurav0 ember-wormhole does not require to use |
@simonihmig you're quite right that needing access to an actual DOM node makes this API hard to use. In addition to your fastboot example, it's just fundamentally timing-dependent in a tricky way. But I also agree that's not a problem this rfc should solve. I don't think it's even a problem glimmer should solve, because it would introduce a lot of complexity into a layer that doesn't need to have it. I would like to continue making ember-elsewhere be a pleasant high-level API. It should adopt in-element as implementation, but also hide the timing dependency for you (so that you can render source and destination in either order, or even put the destination inside a conditional and turn it on and off). All that is easier done in normal "userspace" ember using a service to coordinate. |
@cibernox Can you update the RFC with some of the information in my comment (if you agree with it) or raise questions (if you don't). I think it would be great to FCP this sucker, but @chancancode is right that we need to get the answers to his questions into the text of the RFC. |
I updated the RFC. The only bit I'm not convinced about (or I misunderstood) is the append vs replace. I believe that is not that uncommon to want to wormhole two thing in the same destination. Example: Two dropdown opened simultaneously (not all dropdowns are mutually exclusive). Right now this seems to work with |
@cibernox the concern that @chancancode had, which I want to reiterate, is that supporting I was thinking in the near term it would be fine to just avoid those issues by going with replace semantics for now. Alternatively, if you think the semantics are important, you could figure out how it works now (in terms of all of those questions) and document it in the RFC 😄 |
I would want to second that! So this would require append-semantics, rather than replace. FWIW, Regarding the |
The blockers are fairly clear actually:
Clearly from @cibernox's example (and others) some addon authors have discovered the "magical incantation" and are willing to accept the risk, but that is far from "nothing". 😸
Yep, as mentioned before, I totally agree and is a nice incremental (concept wise) step forward. There is no reason to avoid adding the lower level API now, and adding a better high level API later. |
To be very clear – we don't think anyone should be replacing the addons they are using today with this new API (perhaps the "Motivation" part of the RFC should be more clear about this). The only goal is that there are addons that uses this today and we would like to offer them more stability guarantees (and transitively, to the users of those addons) than today. An API that takes DOM elements are more "primitive" than selectors in several sense:
100% agree that this API is not convenient enough for end-users to adopt, but that's why this is a primitive API for other addons to build on top. |
We discussed this at todays core team meeting, and are still in favor of moving forward. We are also very much interested in further RFCs in this space (e.g. possibly a more user-facing proposal like Thanks to everyone who participated in this RFC! |
I just used |
Rendered