Skip to content

Commit

Permalink
Propagate onInit and onChange handlers in section view
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Nov 30, 2024
1 parent cf3a540 commit d556a07
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/views/layout/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

0 comments on commit d556a07

Please sign in to comment.