BEM class Contains static methods with BEM abstraction to DOM manipulation
Kind: global class
- BEM
- .getBEMNode(block, [element], [modifier]) ⇒
HTMLElement
- .getBEMNodes(block, [element], [modifier]) ⇒
NodeList
- .getChildBEMNode(node, block, [element], [modifier]) ⇒
HTMLElement
- .getChildBEMNodes(node, block, [element], [modifier]) ⇒
HTMLElement
- .getBEMSelector(block, [element], [modifier]) ⇒
string
- .getBEMClassName(block, [element], [modifier]) ⇒
string
- .addModifier(node, modifier, [exp])
- .removeModifier(node, modifier, [exp])
- .toggleModifier(node, modifier, [exp])
- .hasModifier(node, modifier) ⇒
boolean
- .getBEMNode(block, [element], [modifier]) ⇒
Get a node by BEM (Block Element Modifier) description
Kind: static method of BEM
Param | Type | Description |
---|---|---|
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Get multiple nodes by BEM (Block Element Modifier) description
Kind: static method of BEM
Param | Type | Description |
---|---|---|
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Get a child node by BEM (Block Element Modifier) description
Kind: static method of BEM
Param | Type | Description |
---|---|---|
node | HTMLElement |
The parent node |
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Get a child node by BEM (Block Element Modifier) description
Kind: static method of BEM
Param | Type | Description |
---|---|---|
node | HTMLElement |
The parent node |
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Get a BEM (Block Element Modifier) (CSS) selector
Kind: static method of BEM
Param | Type | Description |
---|---|---|
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Get a BEM (Block Element Modifier) class name
Kind: static method of BEM
Param | Type | Description |
---|---|---|
block | string |
The outer block or component |
[element] | string |
An optional element within the outer block |
[modifier] | string |
An optional modifier or (e.g. state or theme) for a block/element |
Add an additional class name with a specific modifier (--modifier) to a BEM (Block Element Modifier) element A modifier class is created for each of the existing class names Class names containing "--" (modifier pattern) are discarded Double class names are prevented
Kind: static method of BEM
Param | Type | Default | Description |
---|---|---|---|
node | HTMLElement |
The block/element to append the class name to (block, block__element) | |
modifier | string |
The name of the modifier (--name) | |
[exp] | boolean |
true |
Optional: If true: add the modifier |
Remove all class names with a specific modifier (--modifier) from a BEM (Block Element Modifier) element
Kind: static method of BEM
Param | Type | Default | Description |
---|---|---|---|
node | HTMLElement |
The block/element to remove the class names from (block, block__element) | |
modifier | string |
The name of the modifier (--name) | |
[exp] | boolean |
true |
Optional: If true: remove the modifier |
Toggles between addModifier() and removeModifier() based on the presence of modifier (--modifier) Block/element names are NOT taken into account while matching
Kind: static method of BEM
Param | Type | Description |
---|---|---|
node | HTMLElement |
The block/element to remove the class names from (block, block__element) |
modifier | string |
The name of the modifier (--name) |
[exp] | boolean |
Optional: If true: add the modifier, if false: remove the modifier |
Returns whether node has modifier (--modifier) Block/element names are NOT taken into account while matching
Kind: static method of BEM
Param | Type | Description |
---|---|---|
node | HTMLElement |
The block/element to check |
modifier | string |
The name of the modifier (--name) |