Allow to execute CableReady operations on StimulusReflex::Element#489
Allow to execute CableReady operations on StimulusReflex::Element#489marcoroth wants to merge 15 commits intostimulusreflex:mainfrom
StimulusReflex::Element#489Conversation
✅ 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?("/") : falseIt 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::Elementinstance which is available aselementin your reflex.This PR enables to call CableReady operations on any instance of the said
StimulusReflex::Elementclass. 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
elementandcontroller_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