fix(lib): peek at the next sibling when iterating to find the child that contains a given descendant
This issue shows up when we have a zero-width token that is the target
descendant node, previously the previous sibling would be returned as
the child that contains the descendant, which is incorrect.
(cherry picked from commit 0a85744eba)
This commit is contained in:
parent
6813e8d5c1
commit
a6b248c1ad
2 changed files with 45 additions and 0 deletions
|
|
@ -290,6 +290,16 @@ fn test_parent_of_zero_width_node() {
|
|||
function_definition
|
||||
);
|
||||
assert_eq!(function_definition.child_containing_descendant(block), None);
|
||||
|
||||
let code = "<script></script>";
|
||||
parser.set_language(&get_language("html")).unwrap();
|
||||
|
||||
let tree = parser.parse(code, None).unwrap();
|
||||
let root = tree.root_node();
|
||||
let script_element = root.child(0).unwrap();
|
||||
let raw_text = script_element.child(1).unwrap();
|
||||
let parent = raw_text.parent().unwrap();
|
||||
assert_eq!(parent, script_element);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue