@@ -105,14 +105,14 @@ _[extends section in The `wasm-bindgen` Guide](https://rustwasm.github.io/docs/w
105105### [ ` JsValue ` ] ( https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html )
106106
107107This is a representation of an object owned by JavaScript, this is a root catch-all type for ` wasm-bindgen ` .
108- Any type that comes from ` wasm-bindgen ` is a ` JsValue ` and this is because JavaScript does not have
109- a strong type system so any function that accepts a variable ` x ` does not define its type so ` x ` can be
110- a valid JavaScript value; hence ` JsValue ` . If you are working with imported functions or types that
108+ Because JavaScript does not have a strong type system, any type that comes from ` wasm-bindgen ` is a ` JsValue ` .
109+ Functions in JavaScript do not define the type of any variables they take in or return; variables can be
110+ any valid JavaScript value, hence ` JsValue ` . If you are working with imported functions or types that
111111accept a ` JsValue ` , then any imported value is _ technically_ valid.
112112
113- ` JsValue ` can be accepted by a function but that function may still only accept certain types and this
114- can lead to panics - so when using raw ` wasm-bindgen ` APIs check the documentation of the JavaScript
115- being imported as to whether an exception (panic) will be raised if that value is not a certain type .
113+ Even though ` JsValue ` may be accepted by a JS function, that function may still only _ actually _ accept certain types.
114+ Passing an incorrect ` JsValue ` can lead to an exception which triggers a panic - so when using raw ` wasm-bindgen ` APIs,
115+ check the your JavaScript's documentation for types of inputs that will cause an exception (and a panic) .
116116
117117_ [ ` JsValue ` documentation] ( https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html ) ._
118118
@@ -125,13 +125,13 @@ that if you have one type which you know is another, then you can use the functi
125125to jump from one type to the other. It is a nice trait to get to know when working with ` web-sys ` ,
126126` wasm_bindgen ` , ` js-sys ` - you will notice lots of types will implement ` JsCast ` from those crates.
127127
128- ` JsCast ` provides both checked and unchecked methods of casting - so that at runtime if you are
129- unsure what type a certain object is you can try to cast it which returns possible failure types like
128+ ` JsCast ` provides both checked and unchecked methods of casting - so if at runtime if you are
129+ unsure what type a certain object is, you can try to cast it, which returns possible failure types like
130130[ ` Option ` ] ( https://doc.rust-lang.org/std/option/enum.Option.html ) and
131131[ ` Result ` ] ( https://doc.rust-lang.org/std/result/enum.Result.html ) .
132132
133133A common example of this in [ ` web-sys ` ] ( ./web-sys.mdx ) is when you are trying to get the
134- target of an event. You might know what the target element is but the
134+ target of an event. You might know what the target element is, but the
135135[ ` web_sys::Event ` ] ( https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html ) API will always return an [ ` Option<web_sys::EventTarget> ` ] ( https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.target ) .
136136You will need to cast it to the element type so you can call its methods.
137137
@@ -157,7 +157,7 @@ fn handle_event(event: Event) {
157157```
158158
159159The [ ` dyn_ref ` ] ( https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_ref )
160- method is a checked cast that returns an ` Option<&T> ` which means the original type
160+ method is a checked cast that returns an ` Option<&T> ` , which means the original type
161161can be used again if the cast failed and thus returned ` None ` . The
162162[ ` dyn_into ` ] ( https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into )
163163method will consume ` self ` , as per convention for ` into ` methods in Rust, and the type returned is
@@ -168,10 +168,10 @@ _[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindg
168168
169169### [ ` Closure ` ] ( https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html )
170170
171- The ` Closure ` type provides a way to transfer Rust closures to JavaScript, the closures passed to
171+ The ` Closure ` type provides a way to transfer Rust closures to JavaScript. The closures passed to
172172JavaScript must have a ` 'static ` lifetime for soundness reasons.
173173
174- This type is a "handle" in the sense that whenever it is dropped it will invalidate the JS
174+ This type is a "handle" in the sense that whenever it is dropped, it will invalidate the JS
175175closure that it refers to. Any usage of the closure in JS after the Closure has been dropped will
176176raise an exception.
177177
@@ -187,7 +187,7 @@ _[`Closure` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bind
187187The ` js-sys ` crate provides bindings/imports of JavaScript's standard, built-in objects, including
188188their methods and properties.
189189
190- This does not include any web APIs as this is what [ ` web-sys ` ] ( ./web-sys.mdx ) is for!
190+ This does not include any web APIs; that's what [ ` web-sys ` ] ( ./web-sys.mdx ) is for!
191191
192192_ [ ` js-sys ` documentation] ( https://rustwasm.github.io/wasm-bindgen/api/js_sys/index.html ) ._
193193
0 commit comments