UNPKG

react-flexigrid

Version:

A React table component designed to allow presenting millions of rows of data.

31 lines (25 loc) 846 B
import { canUseDOM } from './executionEnvironment' const hyphenPattern = /-(.)/g function camelize(str) { return str.replace(hyphenPattern, (_, char) => char.toUpperCase()) } const memoized = {} const prefixes = ['Webkit', 'ms', 'Moz', 'O'] const testStyle = canUseDOM ? document.createElement('div').style : {} function getWithPrefix(name) { for (let i = 0; i < prefixes.length; i += 1) { const prefixedName = prefixes[i] + name if (prefixedName in testStyle) { return prefixedName } } return null } export default function getVendorPrefixedName(property) { const name = camelize(property) if (memoized[name] === undefined) { const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1) memoized[name] = (name in testStyle) ? name : getWithPrefix(capitalizedName) } return memoized[name] }