-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[FEATURE] Allow components in routes #20800
Conversation
Second attempt at #20768 * Refactor to make component the primary path, normalizes templates into a custom component with `{{this}}` set to controller * Keep the core `{{outlet}}` responsibilities separate from what goes into the outlet * Ensures proper debug render tree output – `route-template` node only appears when a template (the custom component) is used * Ensures this works with test-helpers & others that * It doesn't differentiate between components and templates once normalized so `@controller` and `@model` is passed to both TODO: * Feature flag * Test and integrate this in @ember/test-helpers + smoke test * Inlined some TODO comments to investigate/simplify things Co-authored-by: Edward Faulkner <[email protected]>
(This was reworked by @chancancode, I just opened the PR.) |
@chancancode what is the detail on the todo item "integrate this in @ember/test-helpers + smoke test"? The PR does contain an end-to-end smoke test already, and I don't know what would need to change in |
The render test helpers (and perhaps other consumers) reach through private
APIs to directly set outlet state on the “root outlet view” without going
through routing.
TODO Now:
Part of the improvement here is to ensure that code path also works with
components by moving the normalization code out of routing into rendering.
Should have a test to ensure it works.
Can be later:
Said test helpers were updated to support components and does that using
the backwards wrapping into a template trip. With this they should (with
the appropriate version guards, but they already have infra for that) be
able to stop doing that and just pass a component in renderState.template.
I think that would be a good improvement and have few moving parts and
artifacts (avoid additional tracking frames in error messages etc).
If we update the implementation in test helpers, in this repo there is a
specific test files that is supposed to mimic what they are doing to ensure
we don’t accidentally break test helpers. So that should be done together.
Of course could also just move that into this monorepo etc.
…On Fri, Nov 22, 2024 at 12:21 PM Edward Faulkner ***@***.***> wrote:
@chancancode <https://github.com/chancancode> what is the detail on the
todo item "integrate this in @ember/test-helpers + smoke test"?
The PR does contain an end-to-end smoke test already, and I don't know
what would need to change in @ember/test-helpers related to this.
—
Reply to this email directly, view it on GitHub
<#20800 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANUFO4L5U4E52QHYEDSYT2B6G3ZAVCNFSM6AAAAABSKB2KO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJUG4ZDSNJUGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
My understanding of this PR currently is that it's trying to not break the intimate API that |
Not quite, I think we do have tests that tries to roughly cover that already, and indeed I don't think anything I changed would have broken that: https://github.com/emberjs/ember.js/blob/main/packages/ember/tests/ember-test-helpers-test.js What I am saying was that, one key change I made here over the original PR was that I moved the normalization logic outside of the routing layer (when we resolve the route templates) and pushed it into the rendering layer (where we render the outlet). One reason that is an improvement is because ("things like") ember-test-helpers may bypasses the routing code and set the outlet state directly. So the refactor I did ensures that would also work. To that end I think it's good to have some test exercising that code path, confirming setting the outlet state directly with a component actually does work. One way to do that is add another module in the ember-test-helpers smoke test and speculatively change to what we think ember-test-helpers should do moving forward. An artificial unit test somewhere else may also work, but I don't think it'd be that much simpler. |
Got it, thanks. |
Merging this, because in order to truly exercise making ember-test-helpers take advantage of this "new way" it will be easier to do so against an actual ember version that support the feature. We expect everything to already work, and the change in ember-test-helpers is purely cleanup-refactoring, not required for correctness. |
Second attempt at #20768
{{this}}
set to controller{{outlet}}
responsibilities separate from what goes into the outletroute-template
node only appears when a template (the custom component) is used@controller
and@model
is passed to bothTODO: