remove the file engine feature in the html crate (#3392)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-12-20 12:00:03 -08:00
1 parent c2952a79f8
commit aab1258f0e
9 files changed
+65 -66

No files matched your search

+21 -15
View File
@@ -74,25 +74,31 @@ impl HasDragData for Synthetic<DragEvent> {
}
impl HasFileData for Synthetic<DragEvent> {
#[cfg(feature = "file_engine")]
fn files(&self) -> Option<std::sync::Arc<dyn dioxus_html::FileEngine>> {
use wasm_bindgen::JsCast;
let files = self
.event
.dyn_ref::<web_sys::DragEvent>()
.and_then(|drag_event| {
drag_event.data_transfer().and_then(|dt| {
dt.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
#[cfg(feature = "file_engine")]
{
use wasm_bindgen::JsCast;
let files = self
.event
.dyn_ref::<web_sys::DragEvent>()
.and_then(|drag_event| {
drag_event.data_transfer().and_then(|dt| {
dt.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f)
as std::sync::Arc<dyn dioxus_html::FileEngine>
})
})
})
})
});
});
files
files
}
#[cfg(not(feature = "file_engine"))]
{
None
}
}
}
+19 -13
View File
@@ -3,22 +3,28 @@ use dioxus_html::HasFileData;
use super::Synthetic;
impl HasFileData for Synthetic<web_sys::Event> {
#[cfg(feature = "file_engine")]
fn files(&self) -> Option<std::sync::Arc<dyn dioxus_html::FileEngine>> {
use wasm_bindgen::JsCast;
#[cfg(feature = "file_engine")]
{
use wasm_bindgen::JsCast;
let files = self
.event
.dyn_ref()
.and_then(|input: &web_sys::HtmlInputElement| {
input.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
let files = self
.event
.dyn_ref()
.and_then(|input: &web_sys::HtmlInputElement| {
input.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
})
})
})
});
});
files
files
}
#[cfg(not(feature = "file_engine"))]
{
None
}
}
}
+18 -12
View File
@@ -106,21 +106,27 @@ impl HasFormData for WebFormData {
}
impl HasFileData for WebFormData {
#[cfg(feature = "file_engine")]
fn files(&self) -> Option<std::sync::Arc<dyn dioxus_html::FileEngine>> {
let files = self
.element
.dyn_ref()
.and_then(|input: &web_sys::HtmlInputElement| {
input.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
#[cfg(feature = "file_engine")]
{
let files = self
.element
.dyn_ref()
.and_then(|input: &web_sys::HtmlInputElement| {
input.files().and_then(|files| {
#[allow(clippy::arc_with_non_send_sync)]
crate::file_engine::WebFileEngine::new(files).map(|f| {
std::sync::Arc::new(f) as std::sync::Arc<dyn dioxus_html::FileEngine>
})
})
})
});
});
files
files
}
#[cfg(not(feature = "file_engine"))]
{
None
}
}
}