app/assets/javascripts/stimulus_reflex.js in stimulus_reflex-3.5.0.rc3 vs app/assets/javascripts/stimulus_reflex.js in stimulus_reflex-3.5.0.rc4

- old
+ new

@@ -943,11 +943,11 @@ return attrs; }; var name = "stimulus_reflex"; -var version = "3.5.0-rc3"; +var version = "3.5.0-rc4"; var description = "Build reactive applications with the Rails tooling you already know and love."; var keywords = [ "ruby", "rails", "websockets", "actioncable", "turbolinks", "reactive", "cable", "ujs", "ssr", "stimulus", "reflex", "stimulus_reflex", "dom", "morphdom" ]; @@ -1258,11 +1258,11 @@ const controller = controllers.find((controller => { if (!controller || !controller.identifier) return; const identifier = reflexNameToControllerIdentifier(extractReflexName(reflexName)); return identifier === controller.identifier; })); - return controller || controllers[0]; + return controller; }; const scanForReflexes = debounce((() => { const reflexElements = document.querySelectorAll(`[${Schema.reflex}]`); reflexElements.forEach((element => scanForReflexesOnElement(element))); @@ -1279,11 +1279,12 @@ const potentialControllers = [ controller ].concat(allReflexControllers(element)); controller = findControllerByReflexName(reflexName, potentialControllers); const controllerName = controller ? controller.identifier : "stimulus-reflex"; actions.push(`${reflexName.split("->")[0]}->${controllerName}#__perform`); const parentControllerElement = element.closest(`[data-controller~=${controllerName}]`); - if (!parentControllerElement) { + const elementPreviouslyHadStimulusReflexController = element === parentControllerElement && controllerName === "stimulus-reflex"; + if (!parentControllerElement || elementPreviouslyHadStimulusReflexController) { controllers.push(controllerName); } })); const controllerValue = attributeValue(controllers); const actionValue = attributeValue(actions); @@ -1438,10 +1439,11 @@ } })); var StimulusReflex = Object.freeze({ __proto__: null, + StimulusReflexController: StimulusReflexController, initialize: initialize, reflexes: reflexes, register: register, scanForReflexes: scanForReflexes, scanForReflexesOnElement: scanForReflexesOnElement, @@ -1465,6 +1467,6 @@ } }; window.StimulusReflex = global; -export { global as default, initialize, reflexes, register, scanForReflexes, scanForReflexesOnElement, useReflex }; +export { StimulusReflexController, global as default, initialize, reflexes, register, scanForReflexes, scanForReflexesOnElement, useReflex };