-
Notifications
You must be signed in to change notification settings - Fork 437
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
Does the Render
type have the parameter order wrong?
#812
Comments
@seanpdoyle who introduced the |
It looks like it should be defined turbo/src/core/drive/page_renderer.ts Line 161 in 0f3632a
|
@TastyPi thank you for opening this issue. Yes, the order of the arguments in the Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by morphdom's, with the latter argument serving as overrides for the prior argument. Fortunately (and unfortunately!), custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly. In the meantime, I'll open a pull request to swap the order of the arguments for TypeScript's sake. |
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
I've opened #814 to resolve this. |
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
Some documentation would be great, I've just found that my custom rendering logic breaks back/forward navigation and I have no idea why. |
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
Closes [hotwired#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [hotwired#812]: hotwired#812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11
* Correct `Render<E>` method signature argument order Closes [#812][] The order of the arguments in the `Render` signature are incorrect, and [were introduced in that incorrect order][incorrect]. Luckily, the default implementations and the tests that exercise that feature are in the correct order. The signature's argument order was inspired by [morphdom's](https://github.com/patrick-steele-idem/morphdom#usage), with the latter argument serving as overrides for the prior argument. Custom rendering isn't yet covered by Turbo's documentation website, so we have an opportunity to document it thoroughly and correctly, starting with TypeScript's understanding of the interface. [#812]: #812 [incorrect]: https://github.com/hotwired/turbo/pull/431/files#diff-d554b20c605a72c68b2d429ff9915cca4afa8e118026f56ede93382d130382a7R11 * Update `@playwright/test` dependency Our [CI][] is currently failing while executing `yarn run playwright install --with-deps`. This commit updates the dependency in an effort to resolve whatever underlying dependency issues are causing the failure. [CI]: https://github.com/hotwired/turbo/actions/runs/3664875382/jobs/6195570624#step:6:1
I'm not sure if I'm just misunderstanding something or if they are actually the wrong way round, but it took me a while to figure out what the issue was so this at least might help someone figure it out. The Render type is defined as
(newElement: E, currentElement: E) => void
, but it seems like it should be(currentElement: E, newElement: E) => void
. Let me explain.For background: We use Front's live chat widget, and their library adds an iframe to the body than can never be reloaded. This means we need to keep the same body element as well. The original workaround we tried used morphdom, but then we ran into this issue of Stimulus controllers not reloading. So we decided to implement a custom renderer that keeps the body and iframe but copies everything else across.
This is the first attempt:
This doesn't work, it looks like it just removes all the children without copying the new ones across. I assumed the
newElement
was the newly rendered body and thecurrentElement
was the body currently in the DOM. Turns out they're the other way round, and swapping the parameter order made it start working - it looked like it was just removing elements because the elements were being moved the wrong way.The naming of these parameters is very confusing to me, how could the existing DOM be considered the
newElement
? Hence this issue, are the parameters named the wrong way round or am I misunderstanding the meaning of the termsnew
andcurrent
?The text was updated successfully, but these errors were encountered: