Skip to content

Commit

Permalink
fix: :scope not working for dynamically inserted nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenrui committed Mar 8, 2024
1 parent c9b1324 commit e08cd56
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/entity/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Events } from '@/entity/events'
import { Interpreter, ClassInterpreter } from '@/generators/interpreter'
import { kebabToCamelCase } from '@/helpers/strings'
import { State } from '@/state'
import { Mini } from '@/main'

export class Attributes {
static CUSTOM_ATTRIBUTES = [
Expand Down Expand Up @@ -30,6 +31,7 @@ export class Attributes {
}

constructor(entity) {
this.base = new Mini()
this.entity = entity
this.dynamicAttributes = []
this.initialState = { classList: this.entity.element.classList }
Expand Down Expand Up @@ -163,6 +165,10 @@ export class Attributes {

const ids = {}

// null for dynamically inserted nodes
if (window[this.entity.id] == null)
window[this.entity.id] = this.base.state.create({}, this.entity.id)

this.entity.data.scopeVariables.forEach((variable) => {
ids[variable] = `proxyWindow['${this.entity.id}'].${variable}`
})
Expand Down

0 comments on commit e08cd56

Please sign in to comment.