-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Allow to execute CableReady operations on StimulusReflex::Element
#489
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for stimulusreflex ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
0bc4041
to
3e6caf9
Compare
Wooooah this is wild ❤️ Is element.inner_html(html: @count)
element.dispatch_event(name: 'increment', detail: { count: @count })
element.set_focus |
@Matt-Yorkley Yeah, StimulusReflex calls But since calling |
I just gave this a little live-test on top of
Looks like it just needs a single slash instead of a double in -- xpath = selector ? selector.starts_with?("//") : false
++ xpath = selector ? selector.starts_with?("/") : false It works! |
@Matt-Yorkley this is great news, thanks for giving this a shot! |
Type of PR
Feature
Description
As of today we just have one
StimulusReflex::Element
instance which is available aselement
in your reflex.This PR enables to call CableReady operations on any instance of the said
StimulusReflex::Element
class. Like this we enable a very DOM-like and natural API in a reflex action to operate on those elements.Additionally it adds another element accessor to the reflex class named
controller_element
. This is the element in the DOM which holds the Stimulus Controller you are operating on.This enables scenarios like:
This PR is part of a bigger story. The PR #490 proposes the introduction of StimulusReflex targets. With that you can declare any DOM node as a StimulusReflex target (like you do in your Stimulus controller). This enables you to then access and operate on the targets in your Reflexes the same way you can with
element
andcontroller_element
.Why should this be added
Makes the API even more awesome and straight-forward, it feels like you are operating on an actual DOM Node via the actual DOM API. It also makes the use of CableReady more transparent.
Checklist