Change: alias stack for each level type, leads to consistent 'modifier last' rule

This commit is contained in:
reverend 2021-03-09 12:38:47 +01:00
parent 933dbbe2eb
commit baf47d315e

View File

@ -1,6 +1,7 @@
_bem_context = {
_alias_map: {}
_alias_stack: () ()
_alias_stacks: {
}
}
work_stack(stack, callback)
@ -19,17 +20,30 @@ lookup_alias(name)
else
return name
store_alias(alias)
level_name = called-from[1]
if not level_name in _bem_context._alias_stacks
_bem_context._alias_stacks[level_name] = () ()
if alias != null
push(_bem_context._alias_stack, alias)
push(_bem_context._alias_stacks[level_name], alias)
pop_last_alias()
return pop(_bem_context._alias_stack)
level_name = called-from[1]
if not level_name in _bem_context._alias_stacks
return null
return pop(_bem_context._alias_stacks[level_name])
apply_alias_stack(name)
work_stack(_bem_context._alias_stack, @(element){
set_alias(element, name)
})
level_name = called-from[1]
if level_name in _bem_context._alias_stacks
work_stack(_bem_context._alias_stacks[level_name], @(element){
set_alias(element, name)
})
auto_name(delimiter)
if length(called-from) < 3
@ -87,7 +101,7 @@ RV-Block(name)
{block}
_bem_context._alias_map = {}
_bem_context._alias_stack = () ()
_bem_context._alias_stacks = {}
RV-Element(name=null)
+RV-Level(name, '__', ('RV-Block' 'RV-Block--modifier'), @(name){