From 5ca805acd9ec87f931a326a05e11f81f6b7014a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Sat, 16 Nov 2024 16:56:28 +0100 Subject: [PATCH] replace all variables in `@onchange` macro --- src/ReactiveTools.jl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index 33503752..eda58fa3 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -1055,22 +1055,14 @@ macro onchange(location, vars, expr) on_vars = fieldnames_to_fields(vars, known_vars) expr, used_vars = mask(expr, known_vars) - do_vars = Symbol[] - for a in vars.args - push!(do_vars, a isa Symbol && ! in(a, used_vars) ? a : :_) - end - - replace_reactive_vars = setdiff(known_reactive_vars, do_vars) - replace_non_reactive_vars = setdiff(known_non_reactive_vars, do_vars) - - expr = fieldnames_to_fields(expr, known_non_reactive_vars, replace_non_reactive_vars) - expr = fieldnames_to_fieldcontent(expr, known_reactive_vars, replace_reactive_vars) - expr = unmask(expr, vcat(replace_reactive_vars, replace_non_reactive_vars)) + expr = fieldnames_to_fields(expr, known_non_reactive_vars) + expr = fieldnames_to_fieldcontent(expr, known_reactive_vars) + expr = unmask(expr, vcat(known_reactive_vars, known_non_reactive_vars)) fn = length(vars.args) == 1 ? :on : :onany ex = quote - $fn($(on_vars.args...)) do $(do_vars...) + $fn($(on_vars.args...)) do _... $(expr.args...) end end