mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(hooks): namespace.is default state (#5941)
This commit is contained in:
@@ -18,11 +18,14 @@ const TestComp = {
|
||||
ns.be('content', 'active'),
|
||||
ns.em('content', 'active'),
|
||||
ns.bem('body', 'content', 'active'),
|
||||
ns.is('focus'),
|
||||
ns.e(), // return empty string
|
||||
ns.m(), // return empty string
|
||||
ns.be(), // return empty string
|
||||
ns.em(), // return empty string
|
||||
ns.bem(), // return empty string
|
||||
ns.is('hover', undefined), // return empty string
|
||||
ns.is('clicked', false), // return empty string
|
||||
],
|
||||
},
|
||||
'text'
|
||||
@@ -67,6 +70,7 @@ describe('use-locale', () => {
|
||||
'ep-table-content__active', // be('content', 'active')
|
||||
'ep-table__content--active', // em('content', 'active')
|
||||
'ep-table-body__content--active', // bem('body', 'content', 'active')
|
||||
'is-focus', // is('focus')
|
||||
].join('~')
|
||||
)
|
||||
})
|
||||
|
||||
@@ -49,8 +49,13 @@ export const useNamespace = (block: string) => {
|
||||
blockSuffix && element && modifier
|
||||
? _bem(unref(namespace), block, blockSuffix, element, modifier)
|
||||
: ''
|
||||
const is = (name: string, state = true) =>
|
||||
name && state ? `${statePrefix}${name}` : ''
|
||||
const is: {
|
||||
(name: string, state: boolean | undefined): string
|
||||
(name: string): string
|
||||
} = (name: string, ...args: [boolean | undefined] | []) => {
|
||||
const state = args.length >= 1 ? args[0]! : true
|
||||
return name && state ? `${statePrefix}${name}` : ''
|
||||
}
|
||||
return {
|
||||
namespace,
|
||||
b,
|
||||
|
||||
Reference in New Issue
Block a user