From d556a077ae4af73471816fa6d879180a7872a5f9 Mon Sep 17 00:00:00 2001 From: Roman Dvornov Date: Sat, 30 Nov 2024 02:25:49 +0100 Subject: [PATCH] Propagate onInit and onChange handlers in `section` view --- src/views/layout/section.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/views/layout/section.js b/src/views/layout/section.js index d2f642c6..289e6e68 100644 --- a/src/views/layout/section.js +++ b/src/views/layout/section.js @@ -3,11 +3,18 @@ import usage from './section.usage.js'; export default function(host) { host.view.define('section', function(el, config, data, context) { - const { header, content } = config; + const { header, content = [], onInit, onChange } = config; + const mixinHandlersIfNeeded = (config) => + typeof onInit !== 'function' && typeof onChange !== 'function' + ? config // left as is since nothing to mix in + : this.composeConfig(config, { + onInit, + onChange + }); return host.view.render(el, [ - { view: 'header', content: header }, - content + { view: 'header', content: mixinHandlersIfNeeded(header) }, + mixinHandlersIfNeeded(content) ], data, context); }, { usage }); }