Skip to content

Commit 1065662

Browse files
committed
web: Use JsValue::from_bool()
1 parent 12e815d commit 1065662

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

render/canvas/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ impl WebCanvasRenderBackend {
213213
let _ = js_sys::Reflect::set(
214214
&context_options,
215215
&"alpha".into(),
216-
&if is_transparent {
217-
wasm_bindgen::JsValue::TRUE
218-
} else {
219-
wasm_bindgen::JsValue::FALSE
220-
},
216+
&JsValue::from_bool(is_transparent),
221217
);
222218
let context: CanvasRenderingContext2d = canvas
223219
.get_context_with_context_options("2d", &context_options)

render/webgl/src/lib.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,15 @@ impl WebGlRenderBackend {
174174
// Create WebGL context.
175175
let options = [
176176
("stencil", JsValue::TRUE),
177-
(
178-
"alpha",
179-
if is_transparent {
180-
JsValue::TRUE
181-
} else {
182-
JsValue::FALSE
183-
},
184-
),
177+
("alpha", JsValue::from_bool(is_transparent)),
185178
("antialias", JsValue::FALSE),
186179
("depth", JsValue::FALSE),
187180
("failIfMajorPerformanceCaveat", JsValue::TRUE), // fail if no GPU available
188181
("premultipliedAlpha", JsValue::TRUE),
189182
];
190183
let context_options = js_sys::Object::new();
191-
for (name, value) in options.iter() {
192-
js_sys::Reflect::set(&context_options, &JsValue::from(*name), value).warn_on_error();
184+
for (name, value) in options.into_iter() {
185+
js_sys::Reflect::set(&context_options, &JsValue::from(name), &value).warn_on_error();
193186
}
194187

195188
// Attempt to create a WebGL2 context, but fall back to WebGL1 if unavailable.

0 commit comments

Comments
 (0)