mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-21 16:51:33 +00:00
@ -67,7 +67,7 @@
|
||||
- [`static_method_of = Blah`](./reference/attributes/on-js-imports/static_method_of.md)
|
||||
- [`structural`](./reference/attributes/on-js-imports/structural.md)
|
||||
- [`variadic`](./reference/attributes/on-js-imports/variadic.md)
|
||||
- [`polyfill`](./reference/attributes/on-js-imports/polyfill.md)
|
||||
- [`vendor_prefix`](./reference/attributes/on-js-imports/vendor_prefix.md)
|
||||
- [On Rust Exports](./reference/attributes/on-rust-exports/index.md)
|
||||
- [`constructor`](./reference/attributes/on-rust-exports/constructor.md)
|
||||
- [`js_name = Blah`](./reference/attributes/on-rust-exports/js_name.md)
|
||||
|
@ -1,24 +0,0 @@
|
||||
# Polyfilling APIs
|
||||
|
||||
In JS new APIs often have polyfills via different names in various contexts. For
|
||||
example the `AudioContext` API is known as `webkitAudioContext` in Safari at the
|
||||
time of this writing. The `polyfill` attribute indicates these alternative
|
||||
names.
|
||||
|
||||
For example to use `AudioContext` you might do:
|
||||
|
||||
```rust
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
#[wasm_bindgen(polyfill = webkitAudioContext)]
|
||||
type AudioContext;
|
||||
|
||||
// methods on `AudioContext` ...
|
||||
}
|
||||
```
|
||||
|
||||
Whenever `AudioContext` is used it'll use `AudioContext` if the global namespace
|
||||
defines it or alternatively it'll fall back to `webkitAudioContext`.
|
||||
|
||||
Note that `polyfill` cannot be used with `module = "..."` or `js_namespace =
|
||||
...`, so it's basically limited to web-platform APIs today.
|
@ -0,0 +1,24 @@
|
||||
# Vendor-prefixed APIs
|
||||
|
||||
On the web new APIs often have vendor prefixes while they're in an experimental
|
||||
state. For example the `AudioContext` API is known as `webkitAudioContext` in
|
||||
Safari at the time of this writing. The `vendor_prefix` attribute indicates
|
||||
these alternative names, which are used if the normal name isn't defined.
|
||||
|
||||
For example to use `AudioContext` you might do:
|
||||
|
||||
```rust
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
#[wasm_bindgen(vendor_prefix = webkit)]
|
||||
type AudioContext;
|
||||
|
||||
// methods on `AudioContext` ...
|
||||
}
|
||||
```
|
||||
|
||||
Whenever `AudioContext` is used it'll use `AudioContext` if the global namespace
|
||||
defines it or alternatively it'll fall back to `webkitAudioContext`.
|
||||
|
||||
Note that `vendor_prefix` cannot be used with `module = "..."` or
|
||||
`js_namespace = ...`, so it's basically limited to web-platform APIs today.
|
Reference in New Issue
Block a user