From b03b356c8cf486a75a46236625804eadeac7b45d Mon Sep 17 00:00:00 2001 From: miripiruni Date: Tue, 17 Jan 2017 00:16:44 +0300 Subject: [PATCH 1/3] bem-xjst updated to 8.x ***bem-xjst mirgation tool test*** --- common.blocks/attach/__control/attach__control.bemhtml.js | 2 +- common.blocks/button/_type/button_type_link.bemhtml.js | 2 +- common.blocks/button/button.bemhtml.js | 4 ++-- common.blocks/checkbox-group/checkbox-group.bemhtml.js | 4 ++-- common.blocks/checkbox/__control/checkbox__control.bemhtml.js | 2 +- common.blocks/checkbox/__text/checkbox__text.bemhtml.js | 2 +- common.blocks/control-group/control-group.bemhtml.js | 2 +- common.blocks/icon/icon.bemhtml.js | 2 +- common.blocks/image/image.bemhtml.js | 4 ++-- common.blocks/input/__control/input__control.bemhtml.js | 2 +- common.blocks/link/_pseudo/link_pseudo.bemhtml.js | 2 +- common.blocks/link/link.bemhtml.js | 4 ++-- common.blocks/menu/__group/menu__group.bemhtml.js | 4 ++-- common.blocks/menu/__item/menu__item.bemhtml.js | 2 +- common.blocks/menu/menu.bemhtml.js | 4 ++-- common.blocks/modal/modal.bemhtml.js | 4 ++-- common.blocks/popup/popup.bemhtml.js | 2 +- common.blocks/progressbar/progressbar.bemhtml.js | 2 +- common.blocks/radio-group/radio-group.bemhtml.js | 4 ++-- common.blocks/radio/__control/radio__control.bemhtml.js | 2 +- common.blocks/radio/__text/radio__text.bemhtml.js | 2 +- common.blocks/select/__button/select__button.bemhtml.js | 2 +- common.blocks/select/__control/select__control.bemhtml.js | 2 +- common.blocks/textarea/textarea.bemhtml.js | 4 ++-- package.json | 2 +- touch.blocks/input/__control/input__control.bemhtml.js | 2 +- 26 files changed, 35 insertions(+), 35 deletions(-) diff --git a/common.blocks/attach/__control/attach__control.bemhtml.js b/common.blocks/attach/__control/attach__control.bemhtml.js index 08a9c79a9..2af589229 100644 --- a/common.blocks/attach/__control/attach__control.bemhtml.js +++ b/common.blocks/attach/__control/attach__control.bemhtml.js @@ -2,7 +2,7 @@ block('attach').elem('control')( tag()('input'), - attrs()(function() { + addAttrs()(function() { var attrs = { type : 'file' }, attach = this._attach; diff --git a/common.blocks/button/_type/button_type_link.bemhtml.js b/common.blocks/button/_type/button_type_link.bemhtml.js index b0af7d32d..d0c31f99f 100644 --- a/common.blocks/button/_type/button_type_link.bemhtml.js +++ b/common.blocks/button/_type/button_type_link.bemhtml.js @@ -1,7 +1,7 @@ block('button').mod('type', 'link')( tag()('a'), - attrs()(function() { + addAttrs()(function() { var ctx = this.ctx, attrs = { role : 'link' }; diff --git a/common.blocks/button/button.bemhtml.js b/common.blocks/button/button.bemhtml.js index 5bd2221e3..f3a59bca8 100644 --- a/common.blocks/button/button.bemhtml.js +++ b/common.blocks/button/button.bemhtml.js @@ -13,9 +13,9 @@ 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, diff --git a/common.blocks/checkbox-group/checkbox-group.bemhtml.js b/common.blocks/checkbox-group/checkbox-group.bemhtml.js index 8ae9998df..469f60d89 100644 --- a/common.blocks/checkbox-group/checkbox-group.bemhtml.js +++ b/common.blocks/checkbox-group/checkbox-group.bemhtml.js @@ -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, diff --git a/common.blocks/checkbox/__control/checkbox__control.bemhtml.js b/common.blocks/checkbox/__control/checkbox__control.bemhtml.js index 3b596695d..918f0d4f0 100644 --- a/common.blocks/checkbox/__control/checkbox__control.bemhtml.js +++ b/common.blocks/checkbox/__control/checkbox__control.bemhtml.js @@ -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; diff --git a/common.blocks/checkbox/__text/checkbox__text.bemhtml.js b/common.blocks/checkbox/__text/checkbox__text.bemhtml.js index 08b6c8182..e2d08c096 100644 --- a/common.blocks/checkbox/__text/checkbox__text.bemhtml.js +++ b/common.blocks/checkbox/__text/checkbox__text.bemhtml.js @@ -1,4 +1,4 @@ block('checkbox').elem('text')( tag()('span'), - attrs()({ role : 'presentation' }) + addAttrs()({ role : 'presentation' }) ); diff --git a/common.blocks/control-group/control-group.bemhtml.js b/common.blocks/control-group/control-group.bemhtml.js index 69f12d63d..5b35d0332 100644 --- a/common.blocks/control-group/control-group.bemhtml.js +++ b/common.blocks/control-group/control-group.bemhtml.js @@ -1 +1 @@ -block('control-group').attrs()({ role : 'group' }); +block('control-group').addAttrs()({ role : 'group' }); diff --git a/common.blocks/icon/icon.bemhtml.js b/common.blocks/icon/icon.bemhtml.js index 967423687..08f78abad 100644 --- a/common.blocks/icon/icon.bemhtml.js +++ b/common.blocks/icon/icon.bemhtml.js @@ -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 + ')'; diff --git a/common.blocks/image/image.bemhtml.js b/common.blocks/image/image.bemhtml.js index ceb583c71..a9f2b68d7 100644 --- a/common.blocks/image/image.bemhtml.js +++ b/common.blocks/image/image.bemhtml.js @@ -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(), { diff --git a/common.blocks/input/__control/input__control.bemhtml.js b/common.blocks/input/__control/input__control.bemhtml.js index 4e16c3dad..53b96e1ab 100644 --- a/common.blocks/input/__control/input__control.bemhtml.js +++ b/common.blocks/input/__control/input__control.bemhtml.js @@ -1,7 +1,7 @@ block('input').elem('control')( tag()('input'), - attrs()(function() { + addAttrs()(function() { var input = this._input, attrs = { id : input.id, diff --git a/common.blocks/link/_pseudo/link_pseudo.bemhtml.js b/common.blocks/link/_pseudo/link_pseudo.bemhtml.js index 53a5394a6..630258ec7 100644 --- a/common.blocks/link/_pseudo/link_pseudo.bemhtml.js +++ b/common.blocks/link/_pseudo/link_pseudo.bemhtml.js @@ -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' }); }) ); diff --git a/common.blocks/link/link.bemhtml.js b/common.blocks/link/link.bemhtml.js index 462ff9e0b..34049f601 100644 --- a/common.blocks/link/link.bemhtml.js +++ b/common.blocks/link/link.bemhtml.js @@ -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; diff --git a/common.blocks/menu/__group/menu__group.bemhtml.js b/common.blocks/menu/__group/menu__group.bemhtml.js index 3226780aa..dd95e1520 100644 --- a/common.blocks/menu/__group/menu__group.bemhtml.js +++ b/common.blocks/menu/__group/menu__group.bemhtml.js @@ -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() diff --git a/common.blocks/menu/__item/menu__item.bemhtml.js b/common.blocks/menu/__item/menu__item.bemhtml.js index 1b42e33e5..cbda3fcfd 100644 --- a/common.blocks/menu/__item/menu__item.bemhtml.js +++ b/common.blocks/menu/__item/menu__item.bemhtml.js @@ -8,7 +8,7 @@ block('menu').elem('item')( js()(function() { return { val : this.ctx.val }; }), - attrs()(function(){ + addAttrs()(function(){ var elemMods = this.elemMods, menuMode = this._menuMods && this._menuMods.mode, role = menuMode? diff --git a/common.blocks/menu/menu.bemhtml.js b/common.blocks/menu/menu.bemhtml.js index 220f963b8..40dd18b41 100644 --- a/common.blocks/menu/menu.bemhtml.js +++ b/common.blocks/menu/menu.bemhtml.js @@ -39,7 +39,7 @@ block('menu')( _menuMods : mods }); }), - attrs()(function() { + addAttrs()(function() { var attrs = { role : 'menu' }; this.mods.disabled? @@ -49,7 +49,7 @@ block('menu')( return attrs; }), js()(true), - mix()({ elem : 'control' }), + addMix()({ elem : 'control' }), mod('disabled', true) .js()(function() { return this.extend(applyNext(), { tabIndex : 0 }); diff --git a/common.blocks/modal/modal.bemhtml.js b/common.blocks/modal/modal.bemhtml.js index 50e938fa7..3cd0e3fd9 100644 --- a/common.blocks/modal/modal.bemhtml.js +++ b/common.blocks/modal/modal.bemhtml.js @@ -1,7 +1,7 @@ block('modal')( js()(true), - mix()(function() { + addMix()(function() { return { block : 'popup', js : { zIndexGroupLevel : this.ctx.zIndexGroupLevel || 20 }, @@ -9,7 +9,7 @@ block('modal')( }; }), - attrs()({ + addAttrs()({ role : 'dialog', 'aria-hidden' : 'true' }), diff --git a/common.blocks/popup/popup.bemhtml.js b/common.blocks/popup/popup.bemhtml.js index 7e7cc8bb3..6df804b94 100644 --- a/common.blocks/popup/popup.bemhtml.js +++ b/common.blocks/popup/popup.bemhtml.js @@ -9,5 +9,5 @@ block('popup')( zIndexGroupLevel : ctx.zIndexGroupLevel }; }), - attrs()({ 'aria-hidden' : 'true' }) + addAttrs()({ 'aria-hidden' : 'true' }) ); diff --git a/common.blocks/progressbar/progressbar.bemhtml.js b/common.blocks/progressbar/progressbar.bemhtml.js index ef25f4637..15c1d5b68 100644 --- a/common.blocks/progressbar/progressbar.bemhtml.js +++ b/common.blocks/progressbar/progressbar.bemhtml.js @@ -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 */ diff --git a/common.blocks/radio-group/radio-group.bemhtml.js b/common.blocks/radio-group/radio-group.bemhtml.js index 413a60536..34640b3f7 100644 --- a/common.blocks/radio-group/radio-group.bemhtml.js +++ b/common.blocks/radio-group/radio-group.bemhtml.js @@ -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, diff --git a/common.blocks/radio/__control/radio__control.bemhtml.js b/common.blocks/radio/__control/radio__control.bemhtml.js index 1e984e026..de6d20342 100644 --- a/common.blocks/radio/__control/radio__control.bemhtml.js +++ b/common.blocks/radio/__control/radio__control.bemhtml.js @@ -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 = { diff --git a/common.blocks/radio/__text/radio__text.bemhtml.js b/common.blocks/radio/__text/radio__text.bemhtml.js index d6c4129f8..5fc66d82f 100644 --- a/common.blocks/radio/__text/radio__text.bemhtml.js +++ b/common.blocks/radio/__text/radio__text.bemhtml.js @@ -1,6 +1,6 @@ block('radio').elem('text')( tag()('span'), - attrs()(function() { + addAttrs()(function() { return { role : 'presentation' }; }) ); diff --git a/common.blocks/select/__button/select__button.bemhtml.js b/common.blocks/select/__button/select__button.bemhtml.js index f14959b31..cb1a2d389 100644 --- a/common.blocks/select/__button/select__button.bemhtml.js +++ b/common.blocks/select/__button/select__button.bemhtml.js @@ -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 }; }) ); diff --git a/common.blocks/select/__control/select__control.bemhtml.js b/common.blocks/select/__control/select__control.bemhtml.js index 6cd2af276..bc15376c7 100644 --- a/common.blocks/select/__control/select__control.bemhtml.js +++ b/common.blocks/select/__control/select__control.bemhtml.js @@ -1,6 +1,6 @@ block('select').elem('control')( tag()('input'), - attrs()(function() { + addAttrs()(function() { return { type : 'hidden', name : this._select.name, diff --git a/common.blocks/textarea/textarea.bemhtml.js b/common.blocks/textarea/textarea.bemhtml.js index 5a31c632e..3675f5b78 100644 --- a/common.blocks/textarea/textarea.bemhtml.js +++ b/common.blocks/textarea/textarea.bemhtml.js @@ -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, diff --git a/package.json b/package.json index 62f29c897..7b048fb1c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/touch.blocks/input/__control/input__control.bemhtml.js b/touch.blocks/input/__control/input__control.bemhtml.js index fe0a6c2d0..a44ab247c 100644 --- a/touch.blocks/input/__control/input__control.bemhtml.js +++ b/touch.blocks/input/__control/input__control.bemhtml.js @@ -1,6 +1,6 @@ block('input').elem('control')( - attrs()(function() { + addAttrs()(function() { return this.extend({ autocomplete : 'off', autocorrect : 'off', From ca3848505986e115d46418225d672841aaba0258 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Tue, 17 Jan 2017 15:11:55 +0300 Subject: [PATCH 2/3] Manualy fixed --- .jshint-groups.js | 3 +++ .../button/_togglable/button_togglable_check.bemhtml.js | 5 +++-- .../button/_togglable/button_togglable_radio.bemhtml.js | 4 ++-- common.blocks/button/_type/button_type_link.bemhtml.js | 2 +- common.blocks/button/button.bemhtml.js | 5 +++-- common.blocks/menu/__item/menu__item.bemhtml.js | 7 ++++--- common.blocks/menu/menu.bemhtml.js | 6 ++++-- common.blocks/select/select.bemhtml.js | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.jshint-groups.js b/.jshint-groups.js index ec7b1f7ce..b8189d9b7 100644 --- a/.jshint-groups.js +++ b/.jshint-groups.js @@ -62,6 +62,7 @@ module.exports = { 'applyCtx', 'applyNext', 'attrs', + 'addAttrs', 'bem', 'block', 'cls', @@ -69,9 +70,11 @@ module.exports = { 'def', 'elem', 'js', + 'addJs', 'local', 'match', 'mix', + 'addMix', 'mod', 'mode', 'tag', diff --git a/common.blocks/button/_togglable/button_togglable_check.bemhtml.js b/common.blocks/button/_togglable/button_togglable_check.bemhtml.js index ce31b4585..38f43e258 100644 --- a/common.blocks/button/_togglable/button_togglable_check.bemhtml.js +++ b/common.blocks/button/_togglable/button_togglable_check.bemhtml.js @@ -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()); }); diff --git a/common.blocks/button/_togglable/button_togglable_radio.bemhtml.js b/common.blocks/button/_togglable/button_togglable_radio.bemhtml.js index 6e6bcdcd2..5157b878d 100644 --- a/common.blocks/button/_togglable/button_togglable_radio.bemhtml.js +++ b/common.blocks/button/_togglable/button_togglable_radio.bemhtml.js @@ -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) }; }); diff --git a/common.blocks/button/_type/button_type_link.bemhtml.js b/common.blocks/button/_type/button_type_link.bemhtml.js index d0c31f99f..9b8af0eaf 100644 --- a/common.blocks/button/_type/button_type_link.bemhtml.js +++ b/common.blocks/button/_type/button_type_link.bemhtml.js @@ -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) diff --git a/common.blocks/button/button.bemhtml.js b/common.blocks/button/button.bemhtml.js index f3a59bca8..3b36f6db3 100644 --- a/common.blocks/button/button.bemhtml.js +++ b/common.blocks/button/button.bemhtml.js @@ -19,8 +19,9 @@ block('button')( // 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 @@ -43,7 +44,7 @@ block('button')( this.mods.disabled && (attrs.disabled = 'disabled'); - return this.extend(applyNext(), attrs); + return attrs; }) ), diff --git a/common.blocks/menu/__item/menu__item.bemhtml.js b/common.blocks/menu/__item/menu__item.bemhtml.js index cbda3fcfd..e44f50a4e 100644 --- a/common.blocks/menu/__item/menu__item.bemhtml.js +++ b/common.blocks/menu/__item/menu__item.bemhtml.js @@ -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 }; }), 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(), diff --git a/common.blocks/menu/menu.bemhtml.js b/common.blocks/menu/menu.bemhtml.js index 40dd18b41..6f1f2dad8 100644 --- a/common.blocks/menu/menu.bemhtml.js +++ b/common.blocks/menu/menu.bemhtml.js @@ -39,14 +39,16 @@ block('menu')( _menuMods : mods }); }), - addAttrs()(function() { + attrs()(function() { var attrs = { role : 'menu' }; this.mods.disabled? attrs['aria-disabled'] = 'true' : attrs.tabindex = 0; - return attrs; + // extend in backwards order: + // bemjson have more priority + return this.extend(attrs, applyNext()); }), js()(true), addMix()({ elem : 'control' }), diff --git a/common.blocks/select/select.bemhtml.js b/common.blocks/select/select.bemhtml.js index 28c8d7e06..d49dbea74 100644 --- a/common.blocks/select/select.bemhtml.js +++ b/common.blocks/select/select.bemhtml.js @@ -40,7 +40,7 @@ block('select')( }); }), - js()(function() { + addJs()(function() { var ctx = this.ctx; return { name : ctx.name, From b3c8ec42bfb30f7a1247818b2fc7332d81016fcf Mon Sep 17 00:00:00 2001 From: Vladimir Grinenko Date: Sun, 19 Mar 2017 15:21:13 +0300 Subject: [PATCH 3/3] Fixes after review --- .enb/make.js | 5 ++++- .jshint-groups.js | 5 +++-- common.blocks/menu/menu.bemhtml.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.enb/make.js b/.enb/make.js index 8ac8ee53a..d3325d3a1 100644 --- a/.enb/make.js +++ b/.enb/make.js @@ -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 : { diff --git a/.jshint-groups.js b/.jshint-groups.js index b8189d9b7..18154f826 100644 --- a/.jshint-groups.js +++ b/.jshint-groups.js @@ -67,6 +67,8 @@ module.exports = { 'block', 'cls', 'content', + 'appendContent', + 'prependContent', 'def', 'elem', 'js', @@ -80,8 +82,7 @@ module.exports = { 'tag', 'wrap', 'replace', - 'extend', - 'once' + 'extend' ] }, includes : ['*.blocks/**/*.bemhtml.js'] diff --git a/common.blocks/menu/menu.bemhtml.js b/common.blocks/menu/menu.bemhtml.js index 6f1f2dad8..5ff7ee6d2 100644 --- a/common.blocks/menu/menu.bemhtml.js +++ b/common.blocks/menu/menu.bemhtml.js @@ -47,7 +47,7 @@ block('menu')( attrs.tabindex = 0; // extend in backwards order: - // bemjson have more priority + // bemjson has more priority return this.extend(attrs, applyNext()); }), js()(true),