From 7b423995d252ff0c9ff3b1750a2c66634841ce91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Sun, 12 Nov 2023 21:57:40 +0100 Subject: [PATCH] refactor reviver --- assets/js/watchers.js | 19 ++++++------------- src/Elements.jl | 5 ++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/assets/js/watchers.js b/assets/js/watchers.js index 06d7f5dc..47932575 100644 --- a/assets/js/watchers.js +++ b/assets/js/watchers.js @@ -54,20 +54,13 @@ const watcherMixin = { const reviveMixin = { methods: { - revive_payload: function(obj) { - if (typeof obj === 'object') { - for (var key in obj) { - if ( (typeof obj[key] === 'object') && (obj[key]!=null) && !(obj[key].jsfunction) ) { - this.revive_payload(obj[key]) - } else { - if ( (obj[key]!=null) && (obj[key].jsfunction) ) { - obj[key] = Function(obj[key].jsfunction.arguments, obj[key].jsfunction.body) - } - } - } + revive_jsfunction: function (k, v) { + if ( (typeof v==='object') && (v!=null) && (v.jsfunction) ) { + return Function(v.jsfunction.arguments, v.jsfunction.body) + } else { + return v } - return obj; - } + } } } diff --git a/src/Elements.jl b/src/Elements.jl index ec9c204a..255c2bba 100644 --- a/src/Elements.jl +++ b/src/Elements.jl @@ -97,14 +97,13 @@ function vue_integration(::Type{M}; window.parse_payload = function(payload){ if (payload.key) { - window.$(vue_app_name).revive_payload(payload) - window.$(vue_app_name).updateField(payload.key, payload.value); + window.$(vue_app_name).updateField(payload.key, payload.value); } } function app_ready() { $vue_app_name.isready = true; - + Genie.addReviver(window.$(vue_app_name).revive_jsfunction); $(transport == Genie.WebChannels && " try {