Skip to content

Commit

Permalink
chore: Update package.json version to 2.0.10 and fix scoped classes i…
Browse files Browse the repository at this point in the history
…n View.ts
  • Loading branch information
vikraj66 committed Jun 8, 2024
1 parent a0c9bc1 commit 150226c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wayofjs",
"version": "2.0.9",
"version": "2.0.10",
"description": "A library for managing models and views",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 5 additions & 1 deletion src/core/views/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ export abstract class View<T extends Model<K>, K extends HasId> {
applyScopedClasses(element: HTMLElement): void {
if (this.scopedStylesEnabled) {
const classList = Array.from(element.classList);
element.className = classList.map(cls => `${this.uniqueId}-${cls}`).join(' ');
element.className = classList.map(cls =>
cls.startsWith(`${this.uniqueId}-`) ? cls : `${this.uniqueId}-${cls}`
).join(' ');
}
}

applyScopedClassesToAll(element: HTMLElement): void {
if (this.scopedStylesEnabled) {
this.applyScopedClasses(element);
Expand All @@ -74,6 +77,7 @@ export abstract class View<T extends Model<K>, K extends HasId> {
}
}



bindEvents(fragment: DocumentFragment): void {
const eventsMap = this.eventsMap();
Expand Down

0 comments on commit 150226c

Please sign in to comment.