Skip to content

Commit

Permalink
chore: optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kobezzza committed Nov 12, 2024
1 parent 2a89132 commit 8e752b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/snakeskin/default-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function tagFilter({name: tag, attrs = {}}, _, rootTag, forceRenderAsVNode, tplN
}

if (component.inheritMods !== false) {
attrs[':inheritMods'] = ['sharedMods != null'];
// attrs[':inheritMods'] = ['sharedMods != null'];
}

Object.entries(attrs).forEach(([name, val]) => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/super/i-block/modules/mods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type iBlock from 'components/super/i-block/i-block';

export * from 'components/super/i-block/modules/mods/interface';

const sharedModsCache = Object.createDict<ModsDict>();

/**
* Initializes the component modifiers by extracting them from the `modsProps` property,
* attributes of the component whose names match the names of the modifiers described in the static `mods` property
Expand Down Expand Up @@ -129,12 +131,14 @@ export function initMods(component: iBlock['unsafe']): ModsDict {
return;
}

const {sharedMods} = parent;
const sharedMods = sharedModsCache[parent.componentName] ?? parent.sharedMods;

if (sharedMods == null) {
return;
}

sharedModsCache[parent.componentName] = sharedMods;

const modNames = Object.keys(sharedMods);

for (let i = 0; i < modNames.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/super/i-block/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default abstract class iBlockProps extends ComponentInterface {
@prop({type: Object, required: false, forceUpdate: false})
override readonly modsProp?: ModsProp;

@prop({type: Boolean, required: false})
override readonly inheritMods?: boolean;
@prop(Boolean)
override readonly inheritMods: boolean = true;

/**
* If set to true, the component will be activated by default.
Expand Down
2 changes: 1 addition & 1 deletion src/core/component/interface/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export abstract class ComponentInterface {
* If set to true, the component will inherit modifiers from the parent `sharedMods` property.
* This prop is set automatically during the build.
*/
abstract readonly inheritMods?: boolean;
abstract readonly inheritMods: boolean;

/**
* True if the component renders as a regular one, but can be rendered as a functional.
Expand Down

0 comments on commit 8e752b0

Please sign in to comment.