Mirror: CSS prefixing helpers in less than 1KB ๐ŸŒˆ

Add cache to prefixProperty

Changed files
+4 -2
src
+4 -2
src/index.js
···
const ms = 0b001;
const moz = 0b010;
const webkit = 0b100;
+
const cache = {};
export const prefixProperty = prop => {
-
return (msPrefixRe.test(prop) ? ms : 0)
+
if (cache[prop]) return cache[prop];
+
return (cache[prop] = (msPrefixRe.test(prop) ? ms : 0)
| (mozPrefixRe.test(prop) ? moz : 0)
-
| (webkitPrefixRe.test(prop) ? webkit : 0)
+
| (webkitPrefixRe.test(prop) ? webkit : 0));
};
export const prefixValue = (prop, value) => {