Rename polyfill to vendor_prefix

cc #906
This commit is contained in:
Alex Crichton
2018-10-01 12:33:33 -07:00
parent 473258f731
commit f75349262a
14 changed files with 112 additions and 100 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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.