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

Support bem-xjst 8.x #2010

Merged
merged 3 commits into from
Mar 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .enb/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ module.exports = function(config) {
tech : 'enb-bemxjst/techs/bemhtml',
options : {
sourceSuffixes : ['bemhtml.js', 'bemhtml'],
engineOptions : { elemJsInstances : true }
engineOptions : {
elemJsInstances : true,
escapeContent : false
}
}
},
bemhtmlEscaped : {
Expand Down
8 changes: 6 additions & 2 deletions .jshint-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,27 @@ module.exports = {
'applyCtx',
'applyNext',
'attrs',
'addAttrs',
'bem',
'block',
'cls',
'content',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appendContent?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…and prependContent

'appendContent',
'prependContent',
'def',
'elem',
'js',
'addJs',
'local',
'match',
'mix',
'addMix',
'mod',
'mode',
'tag',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we should drop once and extend probably.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extend continue exists

'wrap',
'replace',
'extend',
'once'
'extend'
]
},
includes : ['*.blocks/**/*.bemhtml.js']
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/attach/__control/attach__control.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ block('attach').elem('control')(

tag()('input'),

attrs()(function() {
addAttrs()(function() {
var attrs = { type : 'file' },
attach = this._attach;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
block('button').mod('togglable', 'check').attrs()(function() {
return this.extend(applyNext(), { 'aria-pressed' : String(!!this.mods.checked) });
block('button').mod('togglable', 'check').addAttrs()(function() {
return this.extend({ 'aria-pressed' : String(!!this.mods.checked) },
applyNext());
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
block('button').mod('togglable', 'radio').attrs()(function() {
return this.extend(applyNext(), { 'aria-pressed' : String(!!this.mods.checked) });
block('button').mod('togglable', 'radio').addAttrs()(function() {
return { 'aria-pressed' : String(!!this.mods.checked) };
});
4 changes: 2 additions & 2 deletions common.blocks/button/_type/button_type_link.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('button').mod('type', 'link')(
tag()('a'),

attrs()(function() {
addAttrs()(function() {
var ctx = this.ctx,
attrs = { role : 'link' };

Expand All @@ -10,7 +10,7 @@ block('button').mod('type', 'link')(
attrs['aria-disabled'] = 'true' :
attrs.href = ctx.url;

return this.extend(applyNext(), attrs);
return attrs;
}),

mod('disabled', true)
Expand Down
9 changes: 5 additions & 4 deletions common.blocks/button/button.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ block('button')(
js()(true),

// NOTE: mix below is to satisfy interface of `control`
mix()({ elem : 'control' }),
addMix()({ elem : 'control' }),

attrs()(
addAttrs()(
// Common attributes
function() {
var ctx = this.ctx,
a = applyNext(),
attrs = {
role : 'button',
role : (a && a.role) || 'button',
tabindex : ctx.tabIndex,
id : ctx.id,
title : ctx.title
Expand All @@ -43,7 +44,7 @@ block('button')(

this.mods.disabled && (attrs.disabled = 'disabled');

return this.extend(applyNext(), attrs);
return attrs;
})
),

Expand Down
4 changes: 2 additions & 2 deletions common.blocks/checkbox-group/checkbox-group.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
block('checkbox-group')(
tag()('span'),

attrs()({ role : 'group' }),
addAttrs()({ role : 'group' }),

js()(true),

mix()([{ block : 'control-group' }]),
addMix()([{ block : 'control-group' }]),

content()(function() {
var mods = this.mods,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('checkbox').elem('control')(
tag()('input'),

attrs()(function() {
addAttrs()(function() {
// NOTE: don't remove autocomplete attribute, otherwise js and DOM may be desynced
var attrs = { type : 'checkbox', autocomplete : 'off' },
ctx = this.ctx;
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/checkbox/__text/checkbox__text.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
block('checkbox').elem('text')(
tag()('span'),
attrs()({ role : 'presentation' })
addAttrs()({ role : 'presentation' })
);
2 changes: 1 addition & 1 deletion common.blocks/control-group/control-group.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
block('control-group').attrs()({ role : 'group' });
block('control-group').addAttrs()({ role : 'group' });
2 changes: 1 addition & 1 deletion common.blocks/icon/icon.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
block('icon')(
tag()('span'),
attrs()(function() {
addAttrs()(function() {
var attrs = {},
url = this.ctx.url;
if(url) attrs.style = 'background-image:url(' + url + ')';
Expand Down
4 changes: 2 additions & 2 deletions common.blocks/image/image.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
block('image')(
attrs()({ role : 'img' }),
addAttrs()({ role : 'img' }),

tag()('span'),

match(function() { return typeof this.ctx.content === 'undefined'; })(
tag()('img'),
attrs()(function() {
addAttrs()(function() {
var ctx = this.ctx;
return this.extend(applyNext(),
{
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/input/__control/input__control.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('input').elem('control')(
tag()('input'),

attrs()(function() {
addAttrs()(function() {
var input = this._input,
attrs = {
id : input.id,
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/link/_pseudo/link_pseudo.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
block('link').mod('pseudo', true).match(function() { return !this.ctx.url; })(
tag()('span'),
attrs()(function() {
addAttrs()(function() {
return this.extend(applyNext(), { role : 'button' });
})
);
4 changes: 2 additions & 2 deletions common.blocks/link/link.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ block('link')(
js()(true),

// NOTE: mix below is to satisfy interface of `control`
mix()([{ elem : 'control' }]),
addMix()([{ elem : 'control' }]),

attrs()(function() {
addAttrs()(function() {
var ctx = this.ctx,
attrs = { role : 'link' },
tabIndex;
Expand Down
4 changes: 2 additions & 2 deletions common.blocks/menu/__group/menu__group.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('menu').elem('group')(
attrs()({ role : 'group' }),
addAttrs()({ role : 'group' }),
match(function() { return typeof this.ctx.title !== 'undefined'; })(
attrs()(function() {
addAttrs()(function() {
return this.extend(applyNext(), {
'aria-label' : undefined,
'aria-labelledby' : this.generateId()
Expand Down
9 changes: 5 additions & 4 deletions common.blocks/menu/__item/menu__item.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ block('menu').elem('item')(
elemMods.disabled = elemMods.disabled || this._menuMods.disabled;
return applyNext();
}),
js()(function() {
addJs()(function() {
return { val : this.ctx.val };
}),
attrs()(function(){
addAttrs()(function(){
var elemMods = this.elemMods,
menuMode = this._menuMods && this._menuMods.mode,
role = menuMode?
a = applyNext(),
role = (a && a.role) || (menuMode?
(menuMode === 'check'? 'menuitemcheckbox' : 'menuitemradio') :
'menuitem',
'menuitem'),
attrs = {
role : role,
id : this.ctx.id || this.generateId(),
Expand Down
6 changes: 4 additions & 2 deletions common.blocks/menu/menu.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ block('menu')(
attrs['aria-disabled'] = 'true' :
attrs.tabindex = 0;

return attrs;
// extend in backwards order:
// bemjson has more priority
return this.extend(attrs, applyNext());
}),
js()(true),
mix()({ elem : 'control' }),
addMix()({ elem : 'control' }),
mod('disabled', true)
.js()(function() {
return this.extend(applyNext(), { tabIndex : 0 });
Expand Down
4 changes: 2 additions & 2 deletions common.blocks/modal/modal.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
block('modal')(
js()(true),

mix()(function() {
addMix()(function() {
return {
block : 'popup',
js : { zIndexGroupLevel : this.ctx.zIndexGroupLevel || 20 },
mods : { autoclosable : this.mods.autoclosable }
};
}),

attrs()({
addAttrs()({
role : 'dialog',
'aria-hidden' : 'true'
}),
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/popup/popup.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ block('popup')(
zIndexGroupLevel : ctx.zIndexGroupLevel
};
}),
attrs()({ 'aria-hidden' : 'true' })
addAttrs()({ 'aria-hidden' : 'true' })
);
2 changes: 1 addition & 1 deletion common.blocks/progressbar/progressbar.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ block('progressbar')(
return { val : this._val };
}),

attrs()(function() {
addAttrs()(function() {
return {
role : 'progressbar',
'aria-valuenow' : this._val + '%' /* NOTE: JAWS doesn't add 'percent' automatically */
Expand Down
4 changes: 2 additions & 2 deletions common.blocks/radio-group/radio-group.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
block('radio-group')(
tag()('span'),

attrs()({ role : 'radiogroup' }),
addAttrs()({ role : 'radiogroup' }),

js()(true),

mix()([{ block : 'control-group' }]),
addMix()([{ block : 'control-group' }]),

content()(function() {
var mods = this.mods,
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/radio/__control/radio__control.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('radio').elem('control')(
tag()('input'),

attrs()(function() {
addAttrs()(function() {
// NOTE: don't remove autocomplete attribute, otherwise js and DOM may be desynced
var ctx = this.ctx,
attrs = {
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/radio/__text/radio__text.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
block('radio').elem('text')(
tag()('span'),
attrs()(function() {
addAttrs()(function() {
return { role : 'presentation' };
})
);
2 changes: 1 addition & 1 deletion common.blocks/select/__button/select__button.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ block('select').elem('button')(
);

block('button').elem('text').match(function() { return this._select; })(
attrs()(function() {
addAttrs()(function() {
return { id : this._selectTextId };
})
);
2 changes: 1 addition & 1 deletion common.blocks/select/__control/select__control.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
block('select').elem('control')(
tag()('input'),
attrs()(function() {
addAttrs()(function() {
return {
type : 'hidden',
name : this._select.name,
Expand Down
2 changes: 1 addition & 1 deletion common.blocks/select/select.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ block('select')(
});
}),

js()(function() {
addJs()(function() {
var ctx = this.ctx;
return {
name : ctx.name,
Expand Down
4 changes: 2 additions & 2 deletions common.blocks/textarea/textarea.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ block('textarea')(
tag()('textarea'),

// NOTE: mix below is to satisfy interface of `control`
mix()({ elem : 'control' }),
addMix()({ elem : 'control' }),

attrs()(function() {
addAttrs()(function() {
var ctx = this.ctx,
attrs = {
id : ctx.id,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"enb-bem-specs": "^0.11.0",
"enb-bem-techs": "^2.2.1",
"enb-bem-tmpl-specs": "^1.3.0",
"enb-bemxjst": "^7.0.5",
"enb-bemxjst": "^8.5.2",
"enb-bh": "^1.2.0",
"enb-borschik": "^2.4.0",
"enb-magic-factory": "^0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion touch.blocks/input/__control/input__control.bemhtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
block('input').elem('control')(

attrs()(function() {
addAttrs()(function() {
return this.extend({
autocomplete : 'off',
autocorrect : 'off',
Expand Down