Skip to content

Commit

Permalink
Merge pull request #10 from Group-One-Technology/jr.fix/svg-class
Browse files Browse the repository at this point in the history
Fix: SVG :class not working
  • Loading branch information
jorenrui authored Feb 12, 2024
2 parents 7bf50b7 + cdefac6 commit 2a0246a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/entity/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Attributes {
this.base = base
this.dynamicAttributes = []
this.childClone = null
this.initialState = { className: this.base.element.className }
this.initialState = { classList: this.base.element.classList }

this._getDynamicAttributes()
}
Expand All @@ -35,10 +35,6 @@ export class Attributes {
}
}

get baseClasses() {
return this.initialState.className.split(' ')
}

async evaluate() {
await this.evaluateClass()
await this.evaluateText()
Expand Down Expand Up @@ -69,10 +65,12 @@ export class Attributes {
const expr = this.base.element.getAttribute(':class')
if (!expr) return

this.base.element.className = await this.base._interpret(expr, {
base: this.baseClasses,
const updatedClassNames = await this.base._interpret(expr, {
base: this.initialState.classList,
isClass: true,
})

this.base.element.setAttribute('class', updatedClassNames)
}

async evaluateText() {
Expand Down

0 comments on commit 2a0246a

Please sign in to comment.