mirror of
https://github.com/lexmount/moli.git
synced 2026-10-08 16:01:05 +00:00
fix(selectors): resolve clean textarea directionality
This commit is contained in:
@@ -1703,11 +1703,21 @@ mod tests {
|
||||
|
||||
let textarea = host.create_element("textarea");
|
||||
assert!(host.set_attribute(textarea, "dir", "auto"));
|
||||
assert!(host.set_input_value(textarea, "\u{05ea}"));
|
||||
let textarea_text = host.create_text_node("\u{05ea}");
|
||||
assert!(host.append_child(textarea, textarea_text));
|
||||
assert!(host.append_child(body, textarea));
|
||||
assert!(!engine.matches_host(&host, textarea, ":dir(ltr)").unwrap());
|
||||
assert!(engine.matches_host(&host, textarea, ":dir(rtl)").unwrap());
|
||||
|
||||
assert!(host.set_text_content(textarea, "A"));
|
||||
assert!(engine.matches_host(&host, textarea, ":dir(ltr)").unwrap());
|
||||
assert!(!engine.matches_host(&host, textarea, ":dir(rtl)").unwrap());
|
||||
|
||||
assert!(host.set_input_value(textarea, "\u{05ea}"));
|
||||
assert!(host.set_text_content(textarea, "A"));
|
||||
assert!(!engine.matches_host(&host, textarea, ":dir(ltr)").unwrap());
|
||||
assert!(engine.matches_host(&host, textarea, ":dir(rtl)").unwrap());
|
||||
|
||||
assert!(host.set_input_value(textarea, "A"));
|
||||
assert!(engine.matches_host(&host, textarea, ":dir(ltr)").unwrap());
|
||||
assert!(!engine.matches_host(&host, textarea, ":dir(rtl)").unwrap());
|
||||
|
||||
@@ -739,7 +739,12 @@ pub(crate) fn html_auto_directionality_invalidation_root(
|
||||
fn auto_direction_for_element(host: &DomHost, root: NodeId) -> Option<CssDirection> {
|
||||
if let Some(element) = host.node(root).and_then(Node::as_element) {
|
||||
if element.is_html_textarea() {
|
||||
return first_strong_text_direction(&element.input_value());
|
||||
let value = if element.input_value_dirty() {
|
||||
element.input_value()
|
||||
} else {
|
||||
host.direct_text_content(root).unwrap_or_default()
|
||||
};
|
||||
return first_strong_text_direction(&value);
|
||||
}
|
||||
if element.is_html_input() {
|
||||
return input_auto_direction(element);
|
||||
|
||||
Reference in New Issue
Block a user