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