Skip to content
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

i-bem: more modular way for inheritance from base block (close #428) #429

Merged
merged 1 commit into from
Mar 4, 2014

Conversation

dfilatov
Copy link
Member

@dfilatov dfilatov commented Mar 3, 2014

No description provided.

@dfilatov
Copy link
Member Author

dfilatov commented Mar 3, 2014

@veged @narqo please, take a look

@narqo
Copy link
Member

narqo commented Mar 3, 2014

I guess this will bring more misunderstandings as with bem-events from #394. Don't you think we should have one right way to define blocks instead of three ways*?

modules.define('i-bem__dom', function(provide, BEMDOM) {

BEMDOM.decl('ablock', {});
provide(BEMDOM);

});

modules.define('i-bem__dom', function(provide, BEMDOM) {

BEMDOM.decl({ block : 'ablock', modName : 'm1', modVal : 'v1' }, {});
provide(BEMDOM);

});

vs

modules.define({ block : 'ablock' }, function(provide) {

provide({});

});

modules.define({ block : 'ablock', modName : 'm1', modVal : 'v1' }, function(provide) {

provide({});

});

vs

modules.define('ablock', ['i-bem__dom'], function(provide, BEMDOM) {

provide(BEMDOM.decl('ablock', {}));

});

modules.define('ablock' function(provide, Ablock) {

provide(Ablock.decl({ modName : 'm1', modVal : 'v1' }, {}));

});

`or maybe I haven't caught the idea, sorry

@dfilatov
Copy link
Member Author

dfilatov commented Mar 3, 2014

I guess we have to support and recommend only the one clear true way for each case. The way which introduces minimal patching to modules.define for BEMDOM-blocks.

Inheritance of block from another one

modules.define('ablock', ['i-bem__dom'], function(provide, BEMDOM) {

provide(BEMDOM.decl(this.name, {}));

});

modules.define('bblock', ['i-bem__dom', 'ablock'], function(provide, BEMDOM, ABlock) {

provide(BEMDOM.decl({ block : this.name, baseBlock : ABlock ));

});

Inheritance of block from another level

modules.define('ablock', ['i-bem__dom'], function(provide, BEMDOM) {

provide(BEMDOM.decl(this.name, {}));

});

modules.define('ablock', function(provide, ABlock) {

provide(ABlock.decl({}));

});

Adding modifier to existing block

modules.define('ablock', ['i-bem__dom'], function(provide, BEMDOM) {

provide(BEMDOM.decl(this.name, {}));

});

modules.define('ablock', function(provide, ABlock) {

provide(ABlock.decl({ modName : 'm1', modVal : 'v1' }, {}));

});

@narqo
Copy link
Member

narqo commented Mar 3, 2014

Well, it looks nice

dfilatov added a commit that referenced this pull request Mar 4, 2014
i-bem: more modular way for inheritance from base block (close #428)
@dfilatov dfilatov merged commit e7bbd67 into v2 Mar 4, 2014
@dfilatov dfilatov deleted the issues/428@v2 branch March 4, 2014 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants