diff --git a/components/00_Tools/_bemGenerator.styl b/components/00_Tools/_bemGenerator.styl index 1990cd1..b9c7294 100644 --- a/components/00_Tools/_bemGenerator.styl +++ b/components/00_Tools/_bemGenerator.styl @@ -1,33 +1,33 @@ -_alias_map = {} -_alias_stack = () () +_bem_context = { + _alias_map: {} + _alias_stack: () () +} work_stack(stack, callback) while length(stack) > 0 - entry = pop(_alias_stack) + entry = pop(stack) if entry != () callback(entry) set_alias(alias, name) if name != null && alias != null - _alias_map[alias] = name + _bem_context._alias_map[alias] = name lookup_alias(name) - if not _alias_map - return name - if name in _alias_map - return _alias_map[name] + if name in _bem_context._alias_map + return _bem_context._alias_map[name] else return name store_alias(alias) if alias != null - push(_alias_stack, alias) + push(_bem_context._alias_stack, alias) pop_last_alias() - return pop(_alias_stack) + return pop(_bem_context._alias_stack) apply_alias_stack(name) - work_stack(_alias_stack, @(element){ + work_stack(_bem_context._alias_stack, @(element){ set_alias(element, name) }) @@ -66,7 +66,6 @@ RV-Level(name, name_delimiter, allowed_parent_levels, selector_callback) not_in_parent = true for parent_level in allowed_parent_levels not_in_parent = not_in_parent && not_nested_in(parent_level) - if is_nested_in('RV-Squash') || not_in_parent {block} else if is_nested() @@ -87,9 +86,9 @@ RV-Block(name) .{name} +prefix-classes(name) {block} - - define('_alias_map', {}, true) - define('_alias_stack', () (), true) + + _bem_context._alias_map = {} + _bem_context._alias_stack = () () RV-Element(name=null) +RV-Level(name, '__', ('RV-Block' 'RV-Block--modifier'), @(name){