diff --git a/Cargo.toml b/Cargo.toml
index 8b06146a486..4b31b0db6bf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -95,6 +95,10 @@ features = [
"WorkerOptions",
]
+# Changes here must be reflected in `build.rs`
+[target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dependencies]
+wasm-bindgen = "0.2.58"
+
# Changes here must be reflected in `build.rs`
[target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dev-dependencies]
wasm-bindgen-test = "0.3.4"
@@ -104,15 +108,12 @@ ryu = "1.0.2" # 1.0.1 breaks emscripten
[dev-dependencies]
serde_derive = "1"
-trybuild = "1.0"
-rustversion = "1.0"
[features]
-default = ["services", "agent"]
+default = []
std_web = ["stdweb"]
web_sys = ["console_error_panic_hook", "gloo", "js-sys", "web-sys", "wasm-bindgen"]
doc_test = []
-web_test = []
wasm_test = []
services = []
agent = ["bincode"]
diff --git a/build.rs b/build.rs
index 10705b9ad47..6376e9a727b 100644
--- a/build.rs
+++ b/build.rs
@@ -18,9 +18,7 @@ pub fn main() {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
let using_wasm_bindgen = target_arch == "wasm32" && !using_cargo_web && !using_wasi;
- if using_wasm_bindgen {
- println!("cargo:rustc-cfg=feature=\"wasm_bindgen_test\"");
- } else if cfg!(all(feature = "web_sys", not(feature = "doc_test"))) {
+ if !using_wasm_bindgen && cfg!(all(feature = "web_sys", not(feature = "doc_test"))) {
let target = env::var("TARGET").unwrap_or_default();
panic!(
"Selected target `{}` is not compatible with web-sys",
diff --git a/ci/run_checks.sh b/ci/run_checks.sh
index 65e7ce91cd6..37ecafc7b47 100755
--- a/ci/run_checks.sh
+++ b/ci/run_checks.sh
@@ -8,4 +8,5 @@ fi
set -euxo pipefail
cargo fmt --all -- --check
-cargo clippy -- --deny=warnings
+cargo clippy --features std_web -- --deny=warnings
+cargo clippy --target wasm32-unknown-unknown --features web_sys -- --deny=warnings
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
index 6f80d409d2c..71b17adcdbd 100755
--- a/ci/run_tests.sh
+++ b/ci/run_tests.sh
@@ -5,12 +5,16 @@ set -euxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_
if [ "$emscripten_supported" == "0" ]; then
# TODO - Emscripten builds are broken on rustc > 1.39.0
- cargo web test --features web_test --target asmjs-unknown-emscripten
- cargo web test --features web_test --target wasm32-unknown-emscripten
+ cargo web test --target asmjs-unknown-emscripten --features std_web
+ cargo web test --target wasm32-unknown-emscripten --features std_web
fi
-cargo test --features wasm_test --target wasm32-unknown-unknown
-cargo test --test macro_test
-cargo test --test derive_props_test
-cargo test --doc --all-features
-(cd crates/macro && cargo test --doc)
+cargo test --target wasm32-unknown-unknown --features wasm_test,std_web
+cargo test --target wasm32-unknown-unknown --features wasm_test,web_sys
+cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,std_web
+cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,web_sys
+
+(cd crates/macro \
+ && cargo test --test macro_test \
+ && cargo test --test derive_props_test \
+ && cargo test --doc)
diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml
index 573dbb95b2e..b24411a0b5c 100644
--- a/crates/macro/Cargo.toml
+++ b/crates/macro/Cargo.toml
@@ -25,8 +25,11 @@ proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] }
+# testing
[dev-dependencies]
-yew = { path = "../.." }
+rustversion = "1.0"
+trybuild = "1.0"
+yew = { path = "../..", features = ["std_web"] }
[build-dependencies]
autocfg = "1.0.0"
diff --git a/tests/derive_props/fail.rs b/crates/macro/tests/derive_props/fail.rs
similarity index 100%
rename from tests/derive_props/fail.rs
rename to crates/macro/tests/derive_props/fail.rs
diff --git a/tests/derive_props/fail.stderr b/crates/macro/tests/derive_props/fail.stderr
similarity index 100%
rename from tests/derive_props/fail.stderr
rename to crates/macro/tests/derive_props/fail.stderr
diff --git a/tests/derive_props/pass.rs b/crates/macro/tests/derive_props/pass.rs
similarity index 100%
rename from tests/derive_props/pass.rs
rename to crates/macro/tests/derive_props/pass.rs
diff --git a/tests/derive_props_test.rs b/crates/macro/tests/derive_props_test.rs
similarity index 67%
rename from tests/derive_props_test.rs
rename to crates/macro/tests/derive_props_test.rs
index 82774383256..c72dce3f4a9 100644
--- a/tests/derive_props_test.rs
+++ b/crates/macro/tests/derive_props_test.rs
@@ -1,5 +1,5 @@
#[allow(dead_code)]
-#[rustversion::attr(stable(1.40.0), cfg_attr(not(feature = "web_test"), test))]
+#[rustversion::attr(stable(1.40.0), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_props/pass.rs");
diff --git a/tests/macro/html-block-fail.rs b/crates/macro/tests/macro/html-block-fail.rs
similarity index 100%
rename from tests/macro/html-block-fail.rs
rename to crates/macro/tests/macro/html-block-fail.rs
diff --git a/tests/macro/html-block-fail.stderr b/crates/macro/tests/macro/html-block-fail.stderr
similarity index 100%
rename from tests/macro/html-block-fail.stderr
rename to crates/macro/tests/macro/html-block-fail.stderr
diff --git a/tests/macro/html-block-pass.rs b/crates/macro/tests/macro/html-block-pass.rs
similarity index 100%
rename from tests/macro/html-block-pass.rs
rename to crates/macro/tests/macro/html-block-pass.rs
diff --git a/tests/macro/html-component-fail-unimplemented.rs b/crates/macro/tests/macro/html-component-fail-unimplemented.rs
similarity index 100%
rename from tests/macro/html-component-fail-unimplemented.rs
rename to crates/macro/tests/macro/html-component-fail-unimplemented.rs
diff --git a/tests/macro/html-component-fail-unimplemented.stderr b/crates/macro/tests/macro/html-component-fail-unimplemented.stderr
similarity index 100%
rename from tests/macro/html-component-fail-unimplemented.stderr
rename to crates/macro/tests/macro/html-component-fail-unimplemented.stderr
diff --git a/tests/macro/html-component-fail.rs b/crates/macro/tests/macro/html-component-fail.rs
similarity index 100%
rename from tests/macro/html-component-fail.rs
rename to crates/macro/tests/macro/html-component-fail.rs
diff --git a/tests/macro/html-component-fail.stderr b/crates/macro/tests/macro/html-component-fail.stderr
similarity index 93%
rename from tests/macro/html-component-fail.stderr
rename to crates/macro/tests/macro/html-component-fail.stderr
index 11fbdc5a112..cfd9c2bd9d1 100644
--- a/tests/macro/html-component-fail.stderr
+++ b/crates/macro/tests/macro/html-component-fail.stderr
@@ -188,6 +188,10 @@ error[E0599]: no method named `string` found for type `ChildPropertiesBuilder };
| ^^^^^^ method not found in `ChildPropertiesBuilder`
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `string`, perhaps you need to implement it:
+ candidate #1: `proc_macro::bridge::server::Literal`
error[E0599]: no method named `children` found for type `ChildPropertiesBuilder` in the current scope
--> $DIR/html-component-fail.rs:76:5
@@ -209,6 +213,9 @@ error[E0599]: no method named `build` found for type `ChildContainerPropertiesBu
78 | html! { };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder`
|
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `build`, perhaps you need to implement it:
+ candidate #1: `proc_macro::bridge::server::TokenStreamBuilder`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0599]: no method named `build` found for type `ChildContainerPropertiesBuilder` in the current scope
@@ -220,6 +227,9 @@ error[E0599]: no method named `build` found for type `ChildContainerPropertiesBu
79 | html! { };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder`
|
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `build`, perhaps you need to implement it:
+ candidate #1: `proc_macro::bridge::server::TokenStreamBuilder`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: the trait bound `yew::virtual_dom::vcomp::VChild: std::convert::From<&str>` is not satisfied
diff --git a/tests/macro/html-component-pass.rs b/crates/macro/tests/macro/html-component-pass.rs
similarity index 100%
rename from tests/macro/html-component-pass.rs
rename to crates/macro/tests/macro/html-component-pass.rs
diff --git a/tests/macro/html-iterable-fail.rs b/crates/macro/tests/macro/html-iterable-fail.rs
similarity index 100%
rename from tests/macro/html-iterable-fail.rs
rename to crates/macro/tests/macro/html-iterable-fail.rs
diff --git a/tests/macro/html-iterable-fail.stderr b/crates/macro/tests/macro/html-iterable-fail.stderr
similarity index 100%
rename from tests/macro/html-iterable-fail.stderr
rename to crates/macro/tests/macro/html-iterable-fail.stderr
diff --git a/tests/macro/html-iterable-pass.rs b/crates/macro/tests/macro/html-iterable-pass.rs
similarity index 100%
rename from tests/macro/html-iterable-pass.rs
rename to crates/macro/tests/macro/html-iterable-pass.rs
diff --git a/tests/macro/html-list-fail.rs b/crates/macro/tests/macro/html-list-fail.rs
similarity index 100%
rename from tests/macro/html-list-fail.rs
rename to crates/macro/tests/macro/html-list-fail.rs
diff --git a/tests/macro/html-list-fail.stderr b/crates/macro/tests/macro/html-list-fail.stderr
similarity index 100%
rename from tests/macro/html-list-fail.stderr
rename to crates/macro/tests/macro/html-list-fail.stderr
diff --git a/tests/macro/html-list-pass.rs b/crates/macro/tests/macro/html-list-pass.rs
similarity index 100%
rename from tests/macro/html-list-pass.rs
rename to crates/macro/tests/macro/html-list-pass.rs
diff --git a/tests/macro/html-node-fail.rs b/crates/macro/tests/macro/html-node-fail.rs
similarity index 100%
rename from tests/macro/html-node-fail.rs
rename to crates/macro/tests/macro/html-node-fail.rs
diff --git a/tests/macro/html-node-fail.stderr b/crates/macro/tests/macro/html-node-fail.stderr
similarity index 100%
rename from tests/macro/html-node-fail.stderr
rename to crates/macro/tests/macro/html-node-fail.stderr
diff --git a/tests/macro/html-node-pass.rs b/crates/macro/tests/macro/html-node-pass.rs
similarity index 100%
rename from tests/macro/html-node-pass.rs
rename to crates/macro/tests/macro/html-node-pass.rs
diff --git a/tests/macro/html-tag-fail.rs b/crates/macro/tests/macro/html-tag-fail.rs
similarity index 100%
rename from tests/macro/html-tag-fail.rs
rename to crates/macro/tests/macro/html-tag-fail.rs
diff --git a/tests/macro/html-tag-fail.stderr b/crates/macro/tests/macro/html-tag-fail.stderr
similarity index 100%
rename from tests/macro/html-tag-fail.stderr
rename to crates/macro/tests/macro/html-tag-fail.stderr
diff --git a/tests/macro/html-tag-pass.rs b/crates/macro/tests/macro/html-tag-pass.rs
similarity index 100%
rename from tests/macro/html-tag-pass.rs
rename to crates/macro/tests/macro/html-tag-pass.rs
diff --git a/tests/macro/test_component.rs b/crates/macro/tests/macro/test_component.rs
similarity index 100%
rename from tests/macro/test_component.rs
rename to crates/macro/tests/macro/test_component.rs
diff --git a/tests/macro_test.rs b/crates/macro/tests/macro_test.rs
similarity index 90%
rename from tests/macro_test.rs
rename to crates/macro/tests/macro_test.rs
index de35457c04e..1dc131b3124 100644
--- a/tests/macro_test.rs
+++ b/crates/macro/tests/macro_test.rs
@@ -1,5 +1,5 @@
#[allow(dead_code)]
-#[rustversion::attr(stable(1.40.0), cfg_attr(not(feature = "web_test"), test))]
+#[rustversion::attr(stable(1.40.0), test)]
fn tests() {
let t = trybuild::TestCases::new();
diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml
index 22272744d51..ee19d1cdb3b 100644
--- a/examples/counter/Cargo.toml
+++ b/examples/counter/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
stdweb = "0.4.20"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
diff --git a/examples/crm/Cargo.toml b/examples/crm/Cargo.toml
index 85a4e28e8d8..aaca1ca0a85 100644
--- a/examples/crm/Cargo.toml
+++ b/examples/crm/Cargo.toml
@@ -7,5 +7,5 @@ edition = "2018"
[dependencies]
serde = "1"
serde_derive = "1"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
pulldown-cmark = "0.1.2"
diff --git a/examples/custom_components/Cargo.toml b/examples/custom_components/Cargo.toml
index 0e50867b039..876e9e5c4ef 100644
--- a/examples/custom_components/Cargo.toml
+++ b/examples/custom_components/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Denis Kolodin "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/dashboard/Cargo.toml b/examples/dashboard/Cargo.toml
index f4e0ddb55fd..4bb6ca6a0fb 100644
--- a/examples/dashboard/Cargo.toml
+++ b/examples/dashboard/Cargo.toml
@@ -8,4 +8,4 @@ edition = "2018"
anyhow = "1"
serde = "1"
serde_derive = "1"
-yew = { path = "../..", features = ["toml"] }
+yew = { path = "../..", features = ["std_web", "services", "toml"] }
\ No newline at end of file
diff --git a/examples/file_upload/Cargo.toml b/examples/file_upload/Cargo.toml
index 84d09fe47cc..8a0d34659b3 100644
--- a/examples/file_upload/Cargo.toml
+++ b/examples/file_upload/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Denis Kolodin "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
\ No newline at end of file
diff --git a/examples/fragments/Cargo.toml b/examples/fragments/Cargo.toml
index 7f481560e68..63c48557c59 100644
--- a/examples/fragments/Cargo.toml
+++ b/examples/fragments/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Denis Kolodin "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/futures/Cargo.toml b/examples/futures/Cargo.toml
index 71279cf3483..3af68470c19 100644
--- a/examples/futures/Cargo.toml
+++ b/examples/futures/Cargo.toml
@@ -11,7 +11,7 @@ repository = "https://github.com/yewstack/yew"
crate-type = ["cdylib", "rlib"]
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
wasm-bindgen-futures = "0.4.3"
[dependencies.web-sys]
diff --git a/examples/game_of_life/Cargo.toml b/examples/game_of_life/Cargo.toml
index 26677bce28c..ebaf7a97dcd 100644
--- a/examples/game_of_life/Cargo.toml
+++ b/examples/game_of_life/Cargo.toml
@@ -10,4 +10,4 @@ edition = "2018"
rand = { version = "0.6.5", features = ["stdweb"] }
log = "0.4"
web_logger = "0.1"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
diff --git a/examples/inner_html/Cargo.toml b/examples/inner_html/Cargo.toml
index 37c92c05b64..249ff90e530 100644
--- a/examples/inner_html/Cargo.toml
+++ b/examples/inner_html/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
stdweb = "0.4.20"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/js_callback/Cargo.toml b/examples/js_callback/Cargo.toml
index 242701f9958..6acf4cd225b 100644
--- a/examples/js_callback/Cargo.toml
+++ b/examples/js_callback/Cargo.toml
@@ -5,7 +5,7 @@ authors = ["Scott Steele "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
stdweb = "^0.4.20"
[target.'cfg(all(target_arch = "wasm32", not(cargo_web)))'.dependencies]
diff --git a/examples/large_table/Cargo.toml b/examples/large_table/Cargo.toml
index 67d7196cede..732f460343d 100644
--- a/examples/large_table/Cargo.toml
+++ b/examples/large_table/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["qthree "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/minimal/Cargo.toml b/examples/minimal/Cargo.toml
index ce3b9cdc1dc..77ca2e3753a 100644
--- a/examples/minimal/Cargo.toml
+++ b/examples/minimal/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Denis Kolodin "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/mount_point/Cargo.toml b/examples/mount_point/Cargo.toml
index 675b6281a5b..b477dbd6f48 100644
--- a/examples/mount_point/Cargo.toml
+++ b/examples/mount_point/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
stdweb = "0.4.20"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/multi_thread/Cargo.toml b/examples/multi_thread/Cargo.toml
index 1841175d9b6..25da54fad9e 100644
--- a/examples/multi_thread/Cargo.toml
+++ b/examples/multi_thread/Cargo.toml
@@ -17,4 +17,4 @@ log = "0.4"
web_logger = "0.1"
serde = "1.0"
serde_derive = "1.0"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
diff --git a/examples/nested_list/Cargo.toml b/examples/nested_list/Cargo.toml
index 744148fd54b..24e1e1a50f4 100644
--- a/examples/nested_list/Cargo.toml
+++ b/examples/nested_list/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2018"
[dependencies]
log = "0.4"
web_logger = "0.2"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/examples/node_refs/Cargo.toml b/examples/node_refs/Cargo.toml
index 2cb0ce4acfd..7662541f8e2 100644
--- a/examples/node_refs/Cargo.toml
+++ b/examples/node_refs/Cargo.toml
@@ -5,5 +5,5 @@ authors = ["Justin Starry "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
stdweb = "0.4.20"
diff --git a/examples/npm_and_rest/Cargo.toml b/examples/npm_and_rest/Cargo.toml
index 146b3b7a753..a5b007cdb68 100644
--- a/examples/npm_and_rest/Cargo.toml
+++ b/examples/npm_and_rest/Cargo.toml
@@ -9,4 +9,4 @@ anyhow = "1"
serde = "1"
serde_derive = "1"
stdweb = "0.4.20"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
diff --git a/examples/showcase/Cargo.toml b/examples/showcase/Cargo.toml
index b9acad62070..00b979e5df3 100644
--- a/examples/showcase/Cargo.toml
+++ b/examples/showcase/Cargo.toml
@@ -10,6 +10,8 @@ web_logger = "0.1"
strum = "0.13"
strum_macros = "0.13"
yew = { path = "../.." }
+
+# examples
counter = { path = "../counter" }
crm = { path = "../crm" }
custom_components = { path = "../custom_components" }
diff --git a/examples/textarea/Cargo.toml b/examples/textarea/Cargo.toml
index 2f892e7bed5..6fa2d99ce41 100644
--- a/examples/textarea/Cargo.toml
+++ b/examples/textarea/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Andrew Straw "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
\ No newline at end of file
diff --git a/examples/timer/Cargo.toml b/examples/timer/Cargo.toml
index 8d1e74d3df2..202744da641 100644
--- a/examples/timer/Cargo.toml
+++ b/examples/timer/Cargo.toml
@@ -5,4 +5,4 @@ authors = ["Denis Kolodin "]
edition = "2018"
[dependencies]
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
\ No newline at end of file
diff --git a/examples/todomvc/Cargo.toml b/examples/todomvc/Cargo.toml
index 9b71961e468..4b5a0c5db2c 100644
--- a/examples/todomvc/Cargo.toml
+++ b/examples/todomvc/Cargo.toml
@@ -9,4 +9,4 @@ strum = "0.13"
strum_macros = "0.13"
serde = "1"
serde_derive = "1"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web", "services"] }
\ No newline at end of file
diff --git a/examples/two_apps/Cargo.toml b/examples/two_apps/Cargo.toml
index d080b683938..3051a86595d 100644
--- a/examples/two_apps/Cargo.toml
+++ b/examples/two_apps/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
stdweb = "0.4.20"
-yew = { path = "../.." }
+yew = { path = "../..", features = ["std_web"] }
diff --git a/src/format/macros.rs b/src/format/macros.rs
index f782dfa4fa4..ab7116cfa39 100644
--- a/src/format/macros.rs
+++ b/src/format/macros.rs
@@ -53,6 +53,7 @@ macro_rules! binary_format {
};
}
+#[cfg(any(feature = "bincode", feature = "cbor", feature = "msgpack"))]
macro_rules! text_format_is_an_error {
($type:ident) => {
use $crate::format::FormatError;
diff --git a/tests/vtag_test.rs b/tests/vtag_test.rs
index 94c6b687cb2..8b5daf35ce2 100644
--- a/tests/vtag_test.rs
+++ b/tests/vtag_test.rs
@@ -1,4 +1,6 @@
#![recursion_limit = "128"]
+
+#[cfg(feature = "std_web")]
use stdweb::web::{document, IElement};
#[cfg(feature = "wasm_test")]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
@@ -270,8 +272,16 @@ fn assert_namespace(vtag: &VTag, namespace: &'static str) {
#[test]
fn supports_svg() {
- let div_el = document().create_element("div").unwrap();
- let svg_el = document().create_element_ns(SVG_NAMESPACE, "svg").unwrap();
+ #[cfg(feature = "std_web")]
+ let document = document();
+ #[cfg(feature = "web_sys")]
+ let document = web_sys::window().unwrap().document().unwrap();
+
+ let div_el = document.create_element("div").unwrap();
+ let namespace = SVG_NAMESPACE;
+ #[cfg(feature = "web_sys")]
+ let namespace = Some(namespace);
+ let svg_el = document.create_element_ns(namespace, "svg").unwrap();
let mut g_node = html! { };
let path_node = html! { };