Travis build: 1808

This commit is contained in:
30secondsofcode
2018-03-12 20:31:45 +00:00
parent 62a93e1c71
commit 6adcd00686
3 changed files with 46 additions and 4 deletions

View File

@ -209,6 +209,7 @@ average(1, 2, 3);
* [`off`](#off) * [`off`](#off)
* [`on`](#on) * [`on`](#on)
* [`onUserInputChange`](#onuserinputchange-) * [`onUserInputChange`](#onuserinputchange-)
* [`prefix`](#prefix)
* [`recordAnimationFrames`](#recordanimationframes) * [`recordAnimationFrames`](#recordanimationframes)
* [`redirect`](#redirect) * [`redirect`](#redirect)
* [`runAsync`](#runasync-) * [`runAsync`](#runasync-)
@ -3442,6 +3443,36 @@ onUserInputChange(type => {
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### prefix
Returns the prefixed version (if necessary) of a CSS property that the browser supports.
Use `Array.findIndex()` on an array of vendor prefix strings to test if `document.body` has one of them defined in its `CSSStyleDeclaration` object, otherwise return `null`.
Use `String.charAt()` and `String.toUpperCase()` to capitalize the property, which will be appended to the vendor prefix string.
```js
const prefix = prop => {
const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1);
const prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
const i = prefixes.findIndex(
prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined'
);
return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null;
};
```
<details>
<summary>Examples</summary>
```js
prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitAppearance', 'mozAppearance', 'msAppearance' or 'oAppearance'
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### recordAnimationFrames ### recordAnimationFrames
Invokes the provided callback on each animation frame. Invokes the provided callback on each animation frame.

File diff suppressed because one or more lines are too long

View File

@ -9,9 +9,11 @@ Use `String.charAt()` and `String.toUpperCase()` to capitalize the property, whi
const prefix = prop => { const prefix = prop => {
const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1); const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1);
const prefixes = ['', 'webkit', 'moz', 'ms', 'o']; const prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
const i = prefixes.findIndex(prefix => typeof document.body.style[(prefix ? prefix + capitalizedProp : prop)] !== 'undefined'); const i = prefixes.findIndex(
return i !== -1 ? i === 0 ? prop : prefixes[i] + capitalizedProp : null; prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined'
} );
return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null;
};
``` ```
```js ```js