-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand method in import-notation #288
Conversation
25d60fb
to
16f3739
Compare
16f3739
to
550bbbf
Compare
Example: | ||
|
||
```js | ||
var notation = parse('e:text', { block: 'button' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I didn't understand the difference from parse method.
Actually, I understood but it was not so obvious
add examples of the distinction between them, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we need 2 methods? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! expand
gives us string and it is fast/lightweight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure expand
is the most viable name for this functionality?
I'd suggest:
fullfill
fillup
sate
@@ -1,23 +1,7 @@ | |||
const hashSet = require('hash-set'); | |||
const helpers = require('./lib/helpers'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add to package.json
main.block = ctx.block; | ||
main.elem || ctx.elem && (main.elem = ctx.elem); | ||
} | ||
switch(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why switch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not?
|
||
describe('elem', () => { | ||
it('should copy elem if notation has no elem', () => { | ||
expect(e('m:theme=default', { block : 'button', elem : 'icon' })).to.eql('b:button e:icon m:theme=default'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a test for block_mod
too
('m:theme=default', { block : 'button' })
@@ -70,19 +70,22 @@ describe('block', () => { | |||
describe('context is block', () => { | |||
it('should extract blockMod', () => { | |||
expect(p('m:autoclosable', { block : 'popup' })).to.eql([ | |||
{ block : 'popup' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was here on purpose, so it's not a patch
but since we have a problem with natural dependency in webpack-bem-loader/babel-plugin-bem-import
: bem/webpack-bem-loader#64
maybe we should fix it here.
Need a discussion.
And maybe separate pr. Is it possible @Vittly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made separate pr: #289
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, okey I'll do it after adding expand
modVals = splitMod[1]; | ||
case 'e': | ||
cell.elem = tail; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is strange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add more details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry. we mutating cell
but not adding it to acc
. For the rest types we call acc.add
one or more times.
/** | ||
* Helpers to test import-notation first part | ||
*/ | ||
const tests = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this object. Prob it's enough to make 2 simple functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it a group of functions like templates
object after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, not a blocker.
main.elem || ctx.elem && (main.elem = ctx.elem); | ||
} | ||
switch(type) { | ||
case 'b': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тоже не любишь делать доп отступ для case? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vasiliy не любит =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, it's O2 team code style.
closed in favor of #312 |
Fixing #275.
Also fixed part about "exclude" logic of ctx in parse method (don't know am I right or not). Excluding makes sense only if block requires its modifiers. But I have no real example when it is done. Usually we require modifiers from other blocks and than we need a block too.