File tree Expand file tree Collapse file tree 3 files changed +47
-2
lines changed
Expand file tree Collapse file tree 3 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 3838
3939* [ parse] ( #parsestr-scope )
4040* [ stringify] ( #stringify )
41+ * [ fillup] ( #fillupstr-scope )
42+
43+ ### fillup(str, scope)
44+
45+ Parameter | Type | Description
46+ ----------|----------|--------------------------------------------------------
47+ ` str ` | ` string ` | BEM import notation check [ notation section] ( #notation )
48+ ` scope ` | ` object ` | BEM entity name representation
49+
50+ Fills up given import-notation by context entity to its full form.
51+
52+ Example:
53+
54+ ``` js
55+ fillup (' e:text' , { block: ' button' }) // → 'b:button e:text'
56+ ```
4157
4258### parse(str, [ scope] )
4359
4460Parameter | Type | Description
4561----------|----------|--------------------------------------------------------
4662` str ` | ` string ` | BEM import notation check [ notation section] ( #notation )
47- [ ` scope ` ] | ` object ` | BEM entity name representation.
63+ [ ` scope ` ] | ` object ` | BEM entity name representation
4864
4965Parses the string into BEM entities.
5066
Original file line number Diff line number Diff line change @@ -91,5 +91,6 @@ function stringify(cells) {
9191
9292module . exports = {
9393 parse,
94- stringify
94+ stringify,
95+ fillup : helpers . fillup
9596} ;
Original file line number Diff line number Diff line change 1+ var expect = require ( 'chai' ) . expect ,
2+ f = require ( '..' ) . fillup ;
3+
4+ describe ( 'scope' , ( ) => {
5+ describe ( 'block' , ( ) => {
6+ it ( 'should copy block if notation has no block #1' , ( ) => {
7+ expect ( f ( 'e:icon' , { block : 'button' } ) ) . to . eql ( 'b:button e:icon' ) ;
8+ } ) ;
9+
10+ it ( 'should copy block if notation has no block #2' , ( ) => {
11+ expect ( f ( 'm:theme=default' , { block : 'button' } ) ) . to . eql ( 'b:button m:theme=default' ) ;
12+ } ) ;
13+
14+ it ( 'should not copy block if notation has block' , ( ) => {
15+ expect ( f ( 'b:button e:icon' , { block : 'input' } ) ) . to . eql ( 'b:button e:icon' ) ;
16+ } ) ;
17+ } ) ;
18+
19+ describe ( 'elem' , ( ) => {
20+ it ( 'should copy elem if notation has no elem' , ( ) => {
21+ expect ( f ( 'm:theme=default' , { block : 'button' , elem : 'icon' } ) ) . to . eql ( 'b:button e:icon m:theme=default' ) ;
22+ } ) ;
23+
24+ it ( 'should not copy elem if notation has elem' , ( ) => {
25+ expect ( f ( 'b:button e:icon' , { block : 'input' , elem : 'clear' } ) ) . to . eql ( 'b:button e:icon' ) ;
26+ } ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments