From f1773f7b9e69f91b88623c3c19f3885156b98db8 Mon Sep 17 00:00:00 2001 From: Vladimir Grinenko Date: Tue, 10 Feb 2015 04:46:25 +0300 Subject: [PATCH 1/2] i-bem.bemhtml: Do not repeat block class on mix with same block's mod --- blocks-common/i-bem/__html/i-bem__html.bemhtml | 2 +- .../i-bem/__html/test/files/i-bem/gh-core-804.bemhtml | 1 + .../i-bem/__html/test/files/i-bem/gh-core-804.html | 1 + .../i-bem/__html/test/files/i-bem/gh-core-804.json | 7 +++++++ blocks-common/i-bem/__html/test/i-bem-test.js | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.bemhtml create mode 100644 blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html create mode 100644 blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json diff --git a/blocks-common/i-bem/__html/i-bem__html.bemhtml b/blocks-common/i-bem/__html/i-bem__html.bemhtml index 4c047246..d8019c74 100644 --- a/blocks-common/i-bem/__html/i-bem__html.bemhtml +++ b/blocks-common/i-bem/__html/i-bem__html.bemhtml @@ -389,7 +389,7 @@ default: { if (!mixItem) continue; - var hasItem = mixItem.block || mixItem.elem, + var hasItem = (mixItem.block && (this.block !== v.block || mixItem.block !== this.block)) || mixItem.elem, block = mixItem.block || mixItem._block || this.block, elem = mixItem.elem || mixItem._elem || this.elem, mods = mixItem.mods || this.mods, diff --git a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.bemhtml b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.bemhtml new file mode 100644 index 00000000..113e0603 --- /dev/null +++ b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.bemhtml @@ -0,0 +1 @@ +block b1, mix: { block: 'b2' } diff --git a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html new file mode 100644 index 00000000..f4d94e08 --- /dev/null +++ b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html @@ -0,0 +1 @@ +
diff --git a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json new file mode 100644 index 00000000..5d5d5550 --- /dev/null +++ b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json @@ -0,0 +1,7 @@ +{ + "block": "b1", + "mix": { + "block": "b1", + "mods": { "m1": "v1" } + } +} diff --git a/blocks-common/i-bem/__html/test/i-bem-test.js b/blocks-common/i-bem/__html/test/i-bem-test.js index ec3462a0..aab076f2 100644 --- a/blocks-common/i-bem/__html/test/i-bem-test.js +++ b/blocks-common/i-bem/__html/test/i-bem-test.js @@ -48,6 +48,7 @@ suite('i-bem block and others', function() { unit('applyNext in content regression #289', 'gh-289'); unit('mods redefinition #550', 'gh-550'); unit('block with escaping this', 'escaping-this'); + unit('mix with same block bem-core/804', 'gh-core-804'); test('re-entrance', function() { var t = bemhtml.compile(iBem + readFile('i-bem/re-entrant.bemhtml')); From 708f5d345dc72f46f30fe41bf052cd3a32c3d22c Mon Sep 17 00:00:00 2001 From: Vladimir Grinenko Date: Tue, 10 Feb 2015 23:53:19 +0300 Subject: [PATCH 2/2] i-bem__html: Support mix of elem with same block --- blocks-common/i-bem/__html/i-bem__html.bemhtml | 2 +- .../i-bem/__html/test/files/i-bem/gh-core-804.html | 2 +- .../i-bem/__html/test/files/i-bem/gh-core-804.json | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/blocks-common/i-bem/__html/i-bem__html.bemhtml b/blocks-common/i-bem/__html/i-bem__html.bemhtml index d8019c74..2dfc33a3 100644 --- a/blocks-common/i-bem/__html/i-bem__html.bemhtml +++ b/blocks-common/i-bem/__html/i-bem__html.bemhtml @@ -389,7 +389,7 @@ default: { if (!mixItem) continue; - var hasItem = (mixItem.block && (this.block !== v.block || mixItem.block !== this.block)) || mixItem.elem, + var hasItem = (mixItem.block && (this.block !== v.block || mixItem.block !== this.block)) || this.elem || mixItem.elem, block = mixItem.block || mixItem._block || this.block, elem = mixItem.elem || mixItem._elem || this.elem, mods = mixItem.mods || this.mods, diff --git a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html index f4d94e08..38ca10fb 100644 --- a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html +++ b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.html @@ -1 +1 @@ -
+
diff --git a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json index 5d5d5550..6c8c6c3f 100644 --- a/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json +++ b/blocks-common/i-bem/__html/test/files/i-bem/gh-core-804.json @@ -1,7 +1,18 @@ +[ { "block": "b1", "mix": { "block": "b1", "mods": { "m1": "v1" } } +}, +{ + "block": "b1", + "elem": "e1", + "mix": [{ "block": "b1" }] +}, +{ + "block": "b1", + "mix": [{ "block": "b1", "elem": "e1" }] } +]