From 4fe2c21839ba60225eb8016e06d3e00758086d03 Mon Sep 17 00:00:00 2001 From: reverend Date: Wed, 6 Jan 2021 19:09:08 +0100 Subject: [PATCH] Sanity-Check for parent block --- components/00_Global/_bemGenerator.styl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/components/00_Global/_bemGenerator.styl b/components/00_Global/_bemGenerator.styl index c161e3d..40a1f6f 100644 --- a/components/00_Global/_bemGenerator.styl +++ b/components/00_Global/_bemGenerator.styl @@ -18,14 +18,14 @@ _get_parent_selector() * Gets the selector of the current block */ _get_block_selector() - return split('__', _get_parent_selector())[0] + return unquote(split('__', _get_parent_selector())[0]) /* * Generates a CSS class for an * Block according to BEM */ RV-Block(name) - {_css-prefix}-{name} + .{_css-prefix}-{name} {block} /* @@ -33,7 +33,7 @@ RV-Block(name) * according to BEM. */ RV-Block__Modifier(name) - &{get_block_selector()}--{name} + &{_get_block_selector()}--{name} {block} /* @@ -42,10 +42,9 @@ RV-Block__Modifier(name) * For more see RV-Element___Modifier */ RV-Element(name) - block-selector = get_block_selector() + block-selector = _get_block_selector() // Are we in a block? - if length(block-selector) > 0 - + if block-selector != '&' //Create Selector and output the CSS for the element {block-selector}__{name} {block} @@ -62,7 +61,10 @@ RV-Element(name) name: modifier['name'], modifier_block: modifier['block'] ) - + else + warn('No block found. Creating One instead') + +RV-Block(name) + {block} /* * Generates a CSS class for an element modifier * according to BEM. These are ment to be part of the @@ -74,7 +76,7 @@ RV-Element(name) */ RV-Element__Modifier(name) callback = @(element, name, modifier_block){ - &{get_block_selector()}__{element}--{name}{ + &{_get_block_selector()}__{element}--{name}{ {modifier_block} } }