Skip to content

Commit

Permalink
Fix 3024
Browse files Browse the repository at this point in the history
  • Loading branch information
kachurun authored and GianlucaGuarini committed Oct 18, 2024
1 parent 670f1ad commit affabdb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bindings/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SlotBinding = {
// node: null,
// name: null,
attributes: [],
// templateData: null,
// template: null,

getTemplateScope(scope, parentScope) {
Expand All @@ -39,7 +40,11 @@ export const SlotBinding = {
? scope.slots.find(({ id }) => id === this.name)
: false
const { parentNode } = this.node
const realParent = getRealParent(scope, parentScope)

// if the slot did not pass any content, we will use the self slot for optional fallback content (https://github.com/riot/riot/issues/3024)
const realParent = templateData ? getRealParent(scope, parentScope) : scope

this.templateData = templateData

// override the template property if the slot needs to be replaced
this.template =
Expand Down Expand Up @@ -67,7 +72,10 @@ export const SlotBinding = {
},
update(scope, parentScope) {
if (this.template) {
const realParent = getRealParent(scope, parentScope)
const realParent = this.templateData
? getRealParent(scope, parentScope)
: scope

this.template.update(this.getTemplateScope(scope, realParent), realParent)
}

Expand Down

0 comments on commit affabdb

Please sign in to comment.