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

Make target and targets attributes optional for Stream actions #375

Merged

Conversation

marcoroth
Copy link
Member

@marcoroth marcoroth commented Aug 22, 2022

With the introduction of Custom Stream Actions we can now create Stream Actions that not necessarily require a target attribute to be present.

In order to keep the behaviour we need to raise an ArgumentError if no target was passed to a default stream action helper.

This Pull Request adds a constant with the default actions which require a target or targets attribute to be present. For any other action it will return a regular <turbo-stream> tag without the target attribute.

Edit: This Pull Request removes the check and thus makes the target and targets attributes optional for stream actions.

Related: #373 and #374

@dhh
Copy link
Member

dhh commented Sep 13, 2022

Don't actually think we need this degree of error checking. We're just generating an HTML tag here. Fine to simply allow it not to have a target, and thus be invalid, if the action requires a target.

@marcoroth
Copy link
Member Author

I just added the check so that we can remain the behavior between versions. Because applications could technically rely on this error to be thrown, but I would be fine to remove the check entirely.

@marcoroth marcoroth force-pushed the just-require-target-attribute-for-default-actions branch 3 times, most recently from d9127ef to 0664ee7 Compare September 13, 2022 17:44
@dhh
Copy link
Member

dhh commented Sep 14, 2022

I'd say just remove the check. Don't see how an app will rely on this. It's a failure state.

@marcoroth marcoroth force-pushed the just-require-target-attribute-for-default-actions branch from 0664ee7 to cf30336 Compare September 14, 2022 19:29
@marcoroth marcoroth changed the title Just require target attribute for default Stream Actions Make target and targets attributes optional for Stream actions Sep 14, 2022
@marcoroth marcoroth changed the title Make target and targets attributes optional for Stream actions Make target and targets attributes optional for Stream actions Sep 14, 2022
@marcoroth marcoroth force-pushed the just-require-target-attribute-for-default-actions branch from cf30336 to 6e930ca Compare September 14, 2022 19:32
@marcoroth marcoroth force-pushed the just-require-target-attribute-for-default-actions branch from 6e930ca to 7b0dc1f Compare September 14, 2022 19:34
@dhh dhh merged commit 0225c09 into hotwired:main Sep 19, 2022
@marcoroth marcoroth deleted the just-require-target-attribute-for-default-actions branch March 29, 2023 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants