No Description

prefixes.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. (function() {
  2. var add, crispedges, feature, flexbox, gradients, logicalProps, prefix, resolution, result, sort,
  3. slice = [].slice;
  4. sort = function(array) {
  5. return array.sort(function(a, b) {
  6. var d;
  7. a = a.split(' ');
  8. b = b.split(' ');
  9. if (a[0] > b[0]) {
  10. return 1;
  11. } else if (a[0] < b[0]) {
  12. return -1;
  13. } else {
  14. d = parseFloat(a[1]) - parseFloat(b[1]);
  15. if (d > 0) {
  16. return 1;
  17. } else if (d < 0) {
  18. return -1;
  19. } else {
  20. return 0;
  21. }
  22. }
  23. });
  24. };
  25. feature = function(data, opts, callback) {
  26. var browser, match, need, ref, ref1, support, version, versions;
  27. if (!callback) {
  28. ref = [opts, {}], callback = ref[0], opts = ref[1];
  29. }
  30. match = opts.match || /\sx($|\s)/;
  31. need = [];
  32. ref1 = data.stats;
  33. for (browser in ref1) {
  34. versions = ref1[browser];
  35. for (version in versions) {
  36. support = versions[version];
  37. if (support.match(match)) {
  38. need.push(browser + ' ' + version);
  39. }
  40. }
  41. }
  42. return callback(sort(need));
  43. };
  44. result = {};
  45. prefix = function() {
  46. var data, i, j, k, len, name, names, results;
  47. names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++];
  48. results = [];
  49. for (k = 0, len = names.length; k < len; k++) {
  50. name = names[k];
  51. result[name] = {};
  52. results.push((function() {
  53. var results1;
  54. results1 = [];
  55. for (i in data) {
  56. results1.push(result[name][i] = data[i]);
  57. }
  58. return results1;
  59. })());
  60. }
  61. return results;
  62. };
  63. add = function() {
  64. var data, j, k, len, name, names, results;
  65. names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++];
  66. results = [];
  67. for (k = 0, len = names.length; k < len; k++) {
  68. name = names[k];
  69. results.push(result[name].browsers = sort(result[name].browsers.concat(data.browsers)));
  70. }
  71. return results;
  72. };
  73. module.exports = result;
  74. feature(require('caniuse-db/features-json/border-radius'), function(browsers) {
  75. return prefix('border-radius', 'border-top-left-radius', 'border-top-right-radius', 'border-bottom-right-radius', 'border-bottom-left-radius', {
  76. mistakes: ['-ms-', '-o-'],
  77. transition: true,
  78. browsers: browsers
  79. });
  80. });
  81. feature(require('caniuse-db/features-json/css-boxshadow'), function(browsers) {
  82. return prefix('box-shadow', {
  83. transition: true,
  84. browsers: browsers
  85. });
  86. });
  87. feature(require('caniuse-db/features-json/css-animation'), function(browsers) {
  88. return prefix('animation', 'animation-name', 'animation-duration', 'animation-delay', 'animation-direction', 'animation-fill-mode', 'animation-iteration-count', 'animation-play-state', 'animation-timing-function', '@keyframes', {
  89. mistakes: ['-ms-'],
  90. browsers: browsers
  91. });
  92. });
  93. feature(require('caniuse-db/features-json/css-transitions'), function(browsers) {
  94. return prefix('transition', 'transition-property', 'transition-duration', 'transition-delay', 'transition-timing-function', {
  95. mistakes: ['-ms-'],
  96. browsers: browsers
  97. });
  98. });
  99. feature(require('caniuse-db/features-json/transforms2d'), function(browsers) {
  100. return prefix('transform', 'transform-origin', {
  101. transition: true,
  102. browsers: browsers
  103. });
  104. });
  105. feature(require('caniuse-db/features-json/transforms3d'), function(browsers) {
  106. prefix('perspective', 'perspective-origin', {
  107. transition: true,
  108. browsers: browsers
  109. });
  110. return prefix('transform-style', 'backface-visibility', {
  111. browsers: browsers
  112. });
  113. });
  114. gradients = require('caniuse-db/features-json/css-gradients');
  115. feature(gradients, {
  116. match: /y\sx/
  117. }, function(browsers) {
  118. return prefix('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
  119. props: ['background', 'background-image', 'border-image', 'list-style', 'list-style-image', 'content', 'mask-image', 'mask'],
  120. mistakes: ['-ms-'],
  121. browsers: browsers
  122. });
  123. });
  124. feature(gradients, {
  125. match: /a\sx/
  126. }, function(browsers) {
  127. browsers = browsers.map(function(i) {
  128. if (/op/.test(i)) {
  129. return i;
  130. } else {
  131. return i + " old";
  132. }
  133. });
  134. return add('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
  135. browsers: browsers
  136. });
  137. });
  138. feature(require('caniuse-db/features-json/css3-boxsizing'), function(browsers) {
  139. return prefix('box-sizing', {
  140. browsers: browsers
  141. });
  142. });
  143. feature(require('caniuse-db/features-json/css-filters'), function(browsers) {
  144. return prefix('filter', {
  145. transition: true,
  146. browsers: browsers
  147. });
  148. });
  149. feature(require('caniuse-db/features-json/multicolumn'), function(browsers) {
  150. prefix('columns', 'column-width', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-width', {
  151. transition: true,
  152. browsers: browsers
  153. });
  154. return prefix('column-count', 'column-rule-style', 'column-span', 'column-fill', 'break-before', 'break-after', 'break-inside', {
  155. browsers: browsers
  156. });
  157. });
  158. feature(require('caniuse-db/features-json/user-select-none'), function(browsers) {
  159. return prefix('user-select', {
  160. browsers: browsers
  161. });
  162. });
  163. flexbox = require('caniuse-db/features-json/flexbox');
  164. feature(flexbox, {
  165. match: /a\sx/
  166. }, function(browsers) {
  167. browsers = browsers.map(function(i) {
  168. if (/ie|firefox/.test(i)) {
  169. return i;
  170. } else {
  171. return i + " 2009";
  172. }
  173. });
  174. prefix('display-flex', 'inline-flex', {
  175. props: ['display'],
  176. browsers: browsers
  177. });
  178. prefix('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
  179. transition: true,
  180. browsers: browsers
  181. });
  182. return prefix('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
  183. browsers: browsers
  184. });
  185. });
  186. feature(flexbox, {
  187. match: /y\sx/
  188. }, function(browsers) {
  189. add('display-flex', 'inline-flex', {
  190. browsers: browsers
  191. });
  192. add('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
  193. browsers: browsers
  194. });
  195. return add('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
  196. browsers: browsers
  197. });
  198. });
  199. feature(require('caniuse-db/features-json/calc'), function(browsers) {
  200. return prefix('calc', {
  201. props: ['*'],
  202. browsers: browsers
  203. });
  204. });
  205. feature(require('caniuse-db/features-json/background-img-opts'), function(browsers) {
  206. return prefix('background-clip', 'background-origin', 'background-size', {
  207. browsers: browsers
  208. });
  209. });
  210. feature(require('caniuse-db/features-json/font-feature'), function(browsers) {
  211. return prefix('font-feature-settings', 'font-variant-ligatures', 'font-language-override', 'font-kerning', {
  212. browsers: browsers
  213. });
  214. });
  215. feature(require('caniuse-db/features-json/border-image'), function(browsers) {
  216. return prefix('border-image', {
  217. browsers: browsers
  218. });
  219. });
  220. feature(require('caniuse-db/features-json/css-selection'), function(browsers) {
  221. return prefix('::selection', {
  222. selector: true,
  223. browsers: browsers
  224. });
  225. });
  226. feature(require('caniuse-db/features-json/css-placeholder'), function(browsers) {
  227. browsers = browsers.map(function(i) {
  228. var name, ref, version;
  229. ref = i.split(' '), name = ref[0], version = ref[1];
  230. if (name === 'firefox' && parseFloat(version) <= 18) {
  231. return i + ' old';
  232. } else {
  233. return i;
  234. }
  235. });
  236. return prefix('::placeholder', {
  237. selector: true,
  238. browsers: browsers
  239. });
  240. });
  241. feature(require('caniuse-db/features-json/css-hyphens'), function(browsers) {
  242. return prefix('hyphens', {
  243. browsers: browsers
  244. });
  245. });
  246. feature(require('caniuse-db/features-json/fullscreen'), function(browsers) {
  247. return prefix(':fullscreen', {
  248. selector: true,
  249. browsers: browsers
  250. });
  251. });
  252. feature(require('caniuse-db/features-json/css3-tabsize'), function(browsers) {
  253. return prefix('tab-size', {
  254. browsers: browsers
  255. });
  256. });
  257. feature(require('caniuse-db/features-json/intrinsic-width'), function(browsers) {
  258. return prefix('max-content', 'min-content', 'fit-content', 'fill-available', {
  259. props: ['width', 'min-width', 'max-width', 'height', 'min-height', 'max-height'],
  260. browsers: browsers
  261. });
  262. });
  263. feature(require('caniuse-db/features-json/css3-cursors-newer'), function(browsers) {
  264. prefix('zoom-in', 'zoom-out', {
  265. props: ['cursor'],
  266. browsers: browsers.concat(['chrome 3'])
  267. });
  268. return prefix('grab', 'grabbing', {
  269. props: ['cursor'],
  270. browsers: browsers.concat(['firefox 24', 'firefox 25', 'firefox 26'])
  271. });
  272. });
  273. feature(require('caniuse-db/features-json/css-sticky'), function(browsers) {
  274. return prefix('sticky', {
  275. props: ['position'],
  276. browsers: browsers
  277. });
  278. });
  279. feature(require('caniuse-db/features-json/pointer'), function(browsers) {
  280. return prefix('touch-action', {
  281. browsers: browsers
  282. });
  283. });
  284. feature(require('caniuse-db/features-json/text-decoration'), function(browsers) {
  285. return prefix('text-decoration-style', 'text-decoration-line', 'text-decoration-color', {
  286. browsers: browsers
  287. });
  288. });
  289. feature(require('caniuse-db/features-json/text-size-adjust'), function(browsers) {
  290. return prefix('text-size-adjust', {
  291. browsers: browsers
  292. });
  293. });
  294. feature(require('caniuse-db/features-json/css-masks'), function(browsers) {
  295. prefix('mask-clip', 'mask-composite', 'mask-image', 'mask-origin', 'mask-repeat', {
  296. browsers: browsers
  297. });
  298. return prefix('clip-path', 'mask', 'mask-position', 'mask-size', {
  299. transition: true,
  300. browsers: browsers
  301. });
  302. });
  303. feature(require('caniuse-db/features-json/css-boxdecorationbreak'), function(brwsrs) {
  304. return prefix('box-decoration-break', {
  305. browsers: brwsrs
  306. });
  307. });
  308. feature(require('caniuse-db/features-json/object-fit'), function(browsers) {
  309. return prefix('object-fit', 'object-position', {
  310. browsers: browsers
  311. });
  312. });
  313. feature(require('caniuse-db/features-json/css-shapes'), function(browsers) {
  314. return prefix('shape-margin', 'shape-outside', 'shape-image-threshold', {
  315. browsers: browsers
  316. });
  317. });
  318. feature(require('caniuse-db/features-json/text-overflow'), function(browsers) {
  319. return prefix('text-overflow', {
  320. browsers: browsers
  321. });
  322. });
  323. feature(require('caniuse-db/features-json/text-emphasis'), function(browsers) {
  324. return prefix('text-emphasis', {
  325. browsers: browsers
  326. });
  327. });
  328. feature(require('caniuse-db/features-json/css-deviceadaptation'), function(browsers) {
  329. return prefix('@viewport', {
  330. browsers: browsers
  331. });
  332. });
  333. resolution = require('caniuse-db/features-json/css-media-resolution');
  334. feature(resolution, {
  335. match: /( x($| )|a #3)/
  336. }, function(browsers) {
  337. return prefix('@resolution', {
  338. browsers: browsers
  339. });
  340. });
  341. feature(require('caniuse-db/features-json/css-text-align-last'), function(browsers) {
  342. return prefix('text-align-last', {
  343. browsers: browsers
  344. });
  345. });
  346. crispedges = require('caniuse-db/features-json/css-crisp-edges');
  347. feature(crispedges, {
  348. match: /y x/
  349. }, function(browsers) {
  350. return prefix('pixelated', {
  351. props: ['image-rendering'],
  352. browsers: browsers
  353. });
  354. });
  355. feature(crispedges, {
  356. match: /a x #2/
  357. }, function(browsers) {
  358. return prefix('image-rendering', {
  359. browsers: browsers
  360. });
  361. });
  362. logicalProps = require('caniuse-db/features-json/css-logical-props');
  363. feature(logicalProps, function(browsers) {
  364. return prefix('border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', {
  365. transition: true,
  366. browsers: browsers
  367. });
  368. });
  369. feature(logicalProps, {
  370. match: /x\s#2/
  371. }, function(browsers) {
  372. return prefix('border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', {
  373. transition: true,
  374. browsers: browsers
  375. });
  376. });
  377. feature(require('caniuse-db/features-json/css-appearance'), function(browsers) {
  378. return prefix('appearance', {
  379. browsers: browsers
  380. });
  381. });
  382. }).call(this);