Skip to content

Latest commit

 

History

History
156 lines (112 loc) · 6.58 KB

bem.md

File metadata and controls

156 lines (112 loc) · 6.58 KB

BEM

BEM class Contains static methods with BEM abstraction to DOM manipulation

Kind: global class

BEM.getBEMNode(block, [element], [modifier]) ⇒ HTMLElement

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

BEM.getBEMNodes(block, [element], [modifier]) ⇒ NodeList

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

BEM.getChildBEMNode(node, block, [element], [modifier]) ⇒ HTMLElement

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

BEM.getChildBEMNodes(node, block, [element], [modifier]) ⇒ HTMLElement

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

BEM.getBEMSelector(block, [element], [modifier]) ⇒ string

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

BEM.getBEMClassName(block, [element], [modifier]) ⇒ string

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

BEM.addModifier(node, modifier, [exp])

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

BEM.removeModifier(node, modifier, [exp])

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

BEM.toggleModifier(node, modifier, [exp])

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

BEM.hasModifier(node, modifier) ⇒ boolean

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)