Had to update the 1-behind insertion for partial parameters to account for pseudo elements.
This commit is contained in:
parent
3c9a369908
commit
a0e2ba2b82
@ -17,6 +17,7 @@ use crate::renderer::inline_partial_tree::InlinePartialTreeElement;
|
||||
use crate::renderer::iteration_context::IterationContext;
|
||||
use crate::renderer::parameters_context::ParametersContext;
|
||||
use crate::renderer::walking::walk_path;
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -813,6 +814,15 @@ impl<'a> DustRenderer<'a> {
|
||||
Some(new_stack)
|
||||
}
|
||||
|
||||
fn get_index_of_first_non_pseudo_element<'b, B>(breadcrumbs: &'b Vec<B>) -> Option<usize>
|
||||
where
|
||||
B: Borrow<dyn ContextElement + 'a>,
|
||||
{
|
||||
breadcrumbs
|
||||
.iter()
|
||||
.rposition(|b| !(*b).borrow().is_pseudo_element())
|
||||
}
|
||||
|
||||
fn new_breadcrumbs_partial<'b>(
|
||||
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
||||
explicit_context_breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
||||
@ -837,7 +847,10 @@ impl<'a> DustRenderer<'a> {
|
||||
// added after the current context but before the explicit
|
||||
// context.
|
||||
match explicit_context {
|
||||
None => new_stack.insert(std::cmp::max(new_stack.len() - 1, 0), ctx),
|
||||
None => new_stack.insert(
|
||||
Self::get_index_of_first_non_pseudo_element(&new_stack).unwrap_or(0),
|
||||
ctx,
|
||||
),
|
||||
_ => new_stack.push(ctx),
|
||||
}
|
||||
});
|
||||
|
@ -73,10 +73,6 @@ where
|
||||
== "."
|
||||
{
|
||||
let first_non_pseudo_element = get_first_non_pseudo_element(breadcrumbs);
|
||||
// println!(
|
||||
// "First non-pseudo element: {:?}",
|
||||
// first_non_pseudo_element.map(|b| b.borrow())
|
||||
// );
|
||||
return match first_non_pseudo_element {
|
||||
None => Err(WalkError::CantWalk),
|
||||
Some(current_context) => {
|
||||
|
Loading…
Reference in New Issue
Block a user