fix: implement CharacterData DOM API for jQuery DataTables compatibility (#73)
jQuery DataTables references the standard CharacterData interface which was undefined in obscura's DOM environment, causing ReferenceError and empty page renders. - Add CharacterData class extending Node with data/length/substringData/ appendData/insertData/deleteData/replaceData - Make Text and Comment extend CharacterData instead of Node - Update _wrap() to create proper Text/Comment instances by nodeType - Add create_comment_node op for Document.createComment() - Fix set_text_content to handle Comment node mutations Fixes #72 Co-authored-by: KuaaMU <[email protected]>
This commit is contained in:
1 parent
34205e50d1
commit
86a868bfd6
2 files changed
+64
-9
No files matched your search
@@ -228,8 +228,10 @@ fn op_dom(state: &OpState, #[string] cmd: String, #[string] arg1: String, #[stri
|
||||
"set_text_content" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
dom.with_node_mut(NodeId::new(nid), |n| {
|
||||
if let NodeData::Text { contents } = &mut n.data {
|
||||
*contents = arg2.clone();
|
||||
match &mut n.data {
|
||||
NodeData::Text { contents } => { *contents = arg2.clone(); }
|
||||
NodeData::Comment { contents } => { *contents = arg2.clone(); }
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
"true".into()
|
||||
@@ -246,6 +248,9 @@ fn op_dom(state: &OpState, #[string] cmd: String, #[string] arg1: String, #[stri
|
||||
"create_text_node" => {
|
||||
dom.new_node(NodeData::Text { contents: arg1.clone() }).index().to_string()
|
||||
}
|
||||
"create_comment_node" => {
|
||||
dom.new_node(NodeData::Comment { contents: arg1.clone() }).index().to_string()
|
||||
}
|
||||
"element_children" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
let ids: Vec<i32> = dom.children(NodeId::new(nid)).iter()
|
||||
|
||||
Reference in new issue
Block a user