fix liveview events
This commit is contained in:
1 parent
f20b740abe
commit
1a4741ce04
4 files changed
+11
-8
No files matched your search
@@ -26,7 +26,7 @@ pub struct Mutations<'a> {
|
||||
/// Any templates encountered while diffing the DOM.
|
||||
///
|
||||
/// These must be loaded into a cache before applying the edits
|
||||
pub templates: Vec<Template<'a>>,
|
||||
pub templates: Vec<Template<'static>>,
|
||||
|
||||
/// Any mutations required to patch the renderer to match the layout of the VirtualDom
|
||||
pub edits: Vec<Mutation<'a>>,
|
||||
|
||||
@@ -288,7 +288,7 @@ mod js {
|
||||
#[cfg(not(feature = "web"))]
|
||||
#[bindgen]
|
||||
mod js {
|
||||
const JS_FILE: &str = "./src/interpreter.js";
|
||||
const JS_FILE: &str = "./packages/interpreter/src/interpreter.js";
|
||||
|
||||
fn mount_to_root() {
|
||||
"{AppendChildren(root, stack.length-1);}"
|
||||
@@ -329,10 +329,10 @@ mod js {
|
||||
fn create_text_node(text: &str, id: u32) {
|
||||
"{node = document.createTextNode($text$); nodes[$id$] = node; stack.push(node);}"
|
||||
}
|
||||
fn create_element(element: &str<u8, el>) {
|
||||
fn create_element(element: &'static str<u8, el>) {
|
||||
"{stack.push(document.createElement($element$))}"
|
||||
}
|
||||
fn create_element_ns(element: &str<u8, el>, ns: &str<u8, namespace>) {
|
||||
fn create_element_ns(element: &'static str<u8, el>, ns: &'static str<u8, namespace>) {
|
||||
"{stack.push(document.createElementNS($ns$, $element$))}"
|
||||
}
|
||||
fn create_placeholder(id: u32) {
|
||||
@@ -343,6 +343,7 @@ mod js {
|
||||
}
|
||||
fn new_event_listener(event_name: &str<u8, evt>, id: u32, bubbles: u8) {
|
||||
r#"
|
||||
bubbles = bubbles == 1;
|
||||
node = nodes[id];
|
||||
if(node.listening){
|
||||
node.listening += 1;
|
||||
@@ -352,10 +353,10 @@ mod js {
|
||||
node.setAttribute('data-dioxus-id', `\${id}`);
|
||||
|
||||
// if this is a mounted listener, we send the event immediately
|
||||
if (edit.name === "mounted") {
|
||||
if (event_name === "mounted") {
|
||||
window.ipc.postMessage(
|
||||
serializeIpcMessage("user_event", {
|
||||
name: edit.name,
|
||||
name: event_name,
|
||||
element: edit.id,
|
||||
data: null,
|
||||
bubbles,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const config = new InterpreterConfig(false);
|
||||
|
||||
function main() {
|
||||
let root = window.document.getElementById("main");
|
||||
if (root != null) {
|
||||
|
||||
@@ -248,7 +248,7 @@ pub async fn run(mut vdom: VirtualDom, ws: impl LiveViewSocket) -> Result<(), Li
|
||||
}
|
||||
|
||||
fn add_template(
|
||||
template: &Template,
|
||||
template: &Template<'static>,
|
||||
channel: &mut Channel,
|
||||
templates: &mut FxHashMap<String, u16>,
|
||||
max_template_count: &mut u16,
|
||||
@@ -262,7 +262,7 @@ fn add_template(
|
||||
*max_template_count += 1
|
||||
}
|
||||
|
||||
fn create_template_node(channel: &mut Channel, v: &TemplateNode) {
|
||||
fn create_template_node(channel: &mut Channel, v: &'static TemplateNode<'static>) {
|
||||
use TemplateNode::*;
|
||||
match v {
|
||||
Element {
|
||||
|
||||
Reference in new issue
Block a user