prefixes.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. (function() {
  2. var add, backdropFilter, bckgrndImgOpts, boxdecorbreak, crispedges, cursorsGrab, cursorsNewer, decoration, devdaptation, elementFunction, feature, filterFunction, flexbox, fullscreen, gradients, grid, logicalProps, prefix, readOnly, resolution, result, sort, textAlignLast, textSizeAdjust, textSpacing, transforms3d, userSelectNone, writingMode,
  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.json'), 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: ['-khtml-', '-ms-', '-o-'],
  77. browsers: browsers
  78. });
  79. });
  80. feature(require('caniuse-db/features-json/css-boxshadow.json'), function(browsers) {
  81. return prefix('box-shadow', {
  82. mistakes: ['-khtml-'],
  83. browsers: browsers
  84. });
  85. });
  86. feature(require('caniuse-db/features-json/css-animation.json'), function(browsers) {
  87. return prefix('animation', 'animation-name', 'animation-duration', 'animation-delay', 'animation-direction', 'animation-fill-mode', 'animation-iteration-count', 'animation-play-state', 'animation-timing-function', '@keyframes', {
  88. mistakes: ['-khtml-', '-ms-'],
  89. browsers: browsers
  90. });
  91. });
  92. feature(require('caniuse-db/features-json/css-transitions.json'), function(browsers) {
  93. return prefix('transition', 'transition-property', 'transition-duration', 'transition-delay', 'transition-timing-function', {
  94. mistakes: ['-khtml-', '-ms-'],
  95. browsers: browsers
  96. });
  97. });
  98. feature(require('caniuse-db/features-json/transforms2d.json'), function(browsers) {
  99. return prefix('transform', 'transform-origin', {
  100. browsers: browsers
  101. });
  102. });
  103. transforms3d = require('caniuse-db/features-json/transforms3d.json');
  104. feature(transforms3d, function(browsers) {
  105. prefix('perspective', 'perspective-origin', {
  106. browsers: browsers
  107. });
  108. return prefix('transform-style', {
  109. mistakes: ['-ms-', '-o-'],
  110. browsers: browsers
  111. });
  112. });
  113. feature(transforms3d, {
  114. match: /y\sx|y\s#2/
  115. }, function(browsers) {
  116. return prefix('backface-visibility', {
  117. mistakes: ['-ms-', '-o-'],
  118. browsers: browsers
  119. });
  120. });
  121. gradients = require('caniuse-db/features-json/css-gradients.json');
  122. feature(gradients, {
  123. match: /y\sx/
  124. }, function(browsers) {
  125. return prefix('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
  126. props: ['background', 'background-image', 'border-image', 'mask', 'list-style', 'list-style-image', 'content', 'mask-image'],
  127. mistakes: ['-ms-'],
  128. browsers: browsers
  129. });
  130. });
  131. feature(gradients, {
  132. match: /a\sx/
  133. }, function(browsers) {
  134. browsers = browsers.map(function(i) {
  135. if (/op/.test(i)) {
  136. return i;
  137. } else {
  138. return i + " old";
  139. }
  140. });
  141. return add('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
  142. browsers: browsers
  143. });
  144. });
  145. feature(require('caniuse-db/features-json/css3-boxsizing.json'), function(browsers) {
  146. return prefix('box-sizing', {
  147. browsers: browsers
  148. });
  149. });
  150. feature(require('caniuse-db/features-json/css-filters.json'), function(browsers) {
  151. return prefix('filter', {
  152. browsers: browsers
  153. });
  154. });
  155. filterFunction = require('caniuse-db/features-json/css-filter-function.json');
  156. feature(filterFunction, function(browsers) {
  157. return prefix('filter-function', {
  158. props: ['background', 'background-image', 'border-image', 'mask', 'list-style', 'list-style-image', 'content', 'mask-image'],
  159. browsers: browsers
  160. });
  161. });
  162. backdropFilter = require('caniuse-db/features-json/css-backdrop-filter.json');
  163. feature(backdropFilter, function(browsers) {
  164. return prefix('backdrop-filter', {
  165. browsers: browsers
  166. });
  167. });
  168. elementFunction = require('caniuse-db/features-json/css-element-function.json');
  169. feature(elementFunction, function(browsers) {
  170. return prefix('element', {
  171. props: ['background', 'background-image', 'border-image', 'mask', 'list-style', 'list-style-image', 'content', 'mask-image'],
  172. browsers: browsers
  173. });
  174. });
  175. feature(require('caniuse-db/features-json/multicolumn.json'), function(browsers) {
  176. prefix('columns', 'column-width', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-width', {
  177. browsers: browsers
  178. });
  179. return prefix('column-count', 'column-rule-style', 'column-span', 'column-fill', 'break-before', 'break-after', 'break-inside', {
  180. browsers: browsers
  181. });
  182. });
  183. userSelectNone = require('caniuse-db/features-json/user-select-none.json');
  184. feature(userSelectNone, function(browsers) {
  185. return prefix('user-select', {
  186. mistakes: ['-khtml-'],
  187. browsers: browsers
  188. });
  189. });
  190. flexbox = require('caniuse-db/features-json/flexbox.json');
  191. feature(flexbox, {
  192. match: /a\sx/
  193. }, function(browsers) {
  194. browsers = browsers.map(function(i) {
  195. if (/ie|firefox/.test(i)) {
  196. return i;
  197. } else {
  198. return i + " 2009";
  199. }
  200. });
  201. prefix('display-flex', 'inline-flex', {
  202. props: ['display'],
  203. browsers: browsers
  204. });
  205. prefix('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
  206. browsers: browsers
  207. });
  208. return prefix('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
  209. browsers: browsers
  210. });
  211. });
  212. feature(flexbox, {
  213. match: /y\sx/
  214. }, function(browsers) {
  215. add('display-flex', 'inline-flex', {
  216. browsers: browsers
  217. });
  218. add('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
  219. browsers: browsers
  220. });
  221. return add('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
  222. browsers: browsers
  223. });
  224. });
  225. feature(require('caniuse-db/features-json/calc.json'), function(browsers) {
  226. return prefix('calc', {
  227. props: ['*'],
  228. browsers: browsers
  229. });
  230. });
  231. bckgrndImgOpts = require('caniuse-db/features-json/background-img-opts.json');
  232. feature(bckgrndImgOpts, function(browsers) {
  233. return prefix('background-clip', 'background-origin', 'background-size', {
  234. browsers: browsers
  235. });
  236. });
  237. feature(require('caniuse-db/features-json/font-feature.json'), function(browsers) {
  238. return prefix('font-feature-settings', 'font-variant-ligatures', 'font-language-override', 'font-kerning', {
  239. browsers: browsers
  240. });
  241. });
  242. feature(require('caniuse-db/features-json/border-image.json'), function(browsers) {
  243. return prefix('border-image', {
  244. browsers: browsers
  245. });
  246. });
  247. feature(require('caniuse-db/features-json/css-selection.json'), function(browsers) {
  248. return prefix('::selection', {
  249. selector: true,
  250. browsers: browsers
  251. });
  252. });
  253. feature(require('caniuse-db/features-json/css-placeholder.json'), function(browsers) {
  254. browsers = browsers.map(function(i) {
  255. var name, ref, version;
  256. ref = i.split(' '), name = ref[0], version = ref[1];
  257. if (name === 'firefox' && parseFloat(version) <= 18) {
  258. return i + ' old';
  259. } else {
  260. return i;
  261. }
  262. });
  263. return prefix('::placeholder', {
  264. selector: true,
  265. browsers: browsers
  266. });
  267. });
  268. feature(require('caniuse-db/features-json/css-hyphens.json'), function(browsers) {
  269. return prefix('hyphens', {
  270. browsers: browsers
  271. });
  272. });
  273. fullscreen = require('caniuse-db/features-json/fullscreen.json');
  274. feature(fullscreen, function(browsers) {
  275. return prefix(':fullscreen', {
  276. selector: true,
  277. browsers: browsers
  278. });
  279. });
  280. feature(fullscreen, {
  281. match: /x(\s#2|$)/
  282. }, function(browsers) {
  283. return prefix('::backdrop', {
  284. selector: true,
  285. browsers: browsers
  286. });
  287. });
  288. feature(require('caniuse-db/features-json/css3-tabsize.json'), function(browsers) {
  289. return prefix('tab-size', {
  290. browsers: browsers
  291. });
  292. });
  293. feature(require('caniuse-db/features-json/intrinsic-width.json'), function(browsers) {
  294. return prefix('max-content', 'min-content', 'fit-content', 'fill', 'fill-available', {
  295. props: ['width', 'min-width', 'max-width', 'height', 'min-height', 'max-height', 'inline-size', 'min-inline-size', 'max-inline-size', 'block-size', 'min-block-size', 'max-block-size'],
  296. browsers: browsers
  297. });
  298. });
  299. cursorsNewer = require('caniuse-db/features-json/css3-cursors-newer.json');
  300. feature(cursorsNewer, function(browsers) {
  301. return prefix('zoom-in', 'zoom-out', {
  302. props: ['cursor'],
  303. browsers: browsers
  304. });
  305. });
  306. cursorsGrab = require('caniuse-db/features-json/css3-cursors-grab.json');
  307. feature(cursorsGrab, function(browsers) {
  308. return prefix('grab', 'grabbing', {
  309. props: ['cursor'],
  310. browsers: browsers
  311. });
  312. });
  313. feature(require('caniuse-db/features-json/css-sticky.json'), function(browsers) {
  314. return prefix('sticky', {
  315. props: ['position'],
  316. browsers: browsers
  317. });
  318. });
  319. feature(require('caniuse-db/features-json/pointer.json'), function(browsers) {
  320. return prefix('touch-action', {
  321. browsers: browsers
  322. });
  323. });
  324. decoration = require('caniuse-db/features-json/text-decoration.json');
  325. feature(decoration, function(browsers) {
  326. return prefix('text-decoration-style', 'text-decoration-color', 'text-decoration-line', {
  327. browsers: browsers
  328. });
  329. });
  330. feature(decoration, {
  331. match: /x.*#3/
  332. }, function(browsers) {
  333. return prefix('text-decoration-skip', {
  334. browsers: browsers
  335. });
  336. });
  337. textSizeAdjust = require('caniuse-db/features-json/text-size-adjust.json');
  338. feature(textSizeAdjust, function(browsers) {
  339. return prefix('text-size-adjust', {
  340. browsers: browsers
  341. });
  342. });
  343. feature(require('caniuse-db/features-json/css-masks.json'), function(browsers) {
  344. prefix('mask-clip', 'mask-composite', 'mask-image', 'mask-origin', 'mask-repeat', 'mask-border-repeat', 'mask-border-source', {
  345. browsers: browsers
  346. });
  347. return prefix('clip-path', 'mask', 'mask-position', 'mask-size', 'mask-border', 'mask-border-outset', 'mask-border-width', 'mask-border-slice', {
  348. browsers: browsers
  349. });
  350. });
  351. boxdecorbreak = require('caniuse-db/features-json/css-boxdecorationbreak.json');
  352. feature(boxdecorbreak, function(browsers) {
  353. return prefix('box-decoration-break', {
  354. browsers: browsers
  355. });
  356. });
  357. feature(require('caniuse-db/features-json/object-fit.json'), function(browsers) {
  358. return prefix('object-fit', 'object-position', {
  359. browsers: browsers
  360. });
  361. });
  362. feature(require('caniuse-db/features-json/css-shapes.json'), function(browsers) {
  363. return prefix('shape-margin', 'shape-outside', 'shape-image-threshold', {
  364. browsers: browsers
  365. });
  366. });
  367. feature(require('caniuse-db/features-json/text-overflow.json'), function(browsers) {
  368. return prefix('text-overflow', {
  369. browsers: browsers
  370. });
  371. });
  372. devdaptation = require('caniuse-db/features-json/css-deviceadaptation.json');
  373. feature(devdaptation, function(browsers) {
  374. return prefix('@viewport', {
  375. browsers: browsers
  376. });
  377. });
  378. resolution = require('caniuse-db/features-json/css-media-resolution.json');
  379. feature(resolution, {
  380. match: /( x($| )|a #3)/
  381. }, function(browsers) {
  382. return prefix('@resolution', {
  383. browsers: browsers
  384. });
  385. });
  386. textAlignLast = require('caniuse-db/features-json/css-text-align-last.json');
  387. feature(textAlignLast, function(browsers) {
  388. return prefix('text-align-last', {
  389. browsers: browsers
  390. });
  391. });
  392. crispedges = require('caniuse-db/features-json/css-crisp-edges.json');
  393. feature(crispedges, {
  394. match: /y x|a x #1/
  395. }, function(browsers) {
  396. return prefix('pixelated', {
  397. props: ['image-rendering'],
  398. browsers: browsers
  399. });
  400. });
  401. feature(crispedges, {
  402. match: /a x #2/
  403. }, function(browsers) {
  404. return prefix('image-rendering', {
  405. browsers: browsers
  406. });
  407. });
  408. logicalProps = require('caniuse-db/features-json/css-logical-props.json');
  409. feature(logicalProps, function(browsers) {
  410. return prefix('border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', {
  411. browsers: browsers
  412. });
  413. });
  414. feature(logicalProps, {
  415. match: /x\s#2/
  416. }, function(browsers) {
  417. return prefix('border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', {
  418. browsers: browsers
  419. });
  420. });
  421. feature(require('caniuse-db/features-json/css-appearance.json'), function(browsers) {
  422. return prefix('appearance', {
  423. browsers: browsers
  424. });
  425. });
  426. feature(require('caniuse-db/features-json/css-snappoints.json'), function(browsers) {
  427. return prefix('scroll-snap-type', 'scroll-snap-coordinate', 'scroll-snap-destination', 'scroll-snap-points-x', 'scroll-snap-points-y', {
  428. browsers: browsers
  429. });
  430. });
  431. feature(require('caniuse-db/features-json/css-regions.json'), function(browsers) {
  432. return prefix('flow-into', 'flow-from', 'region-fragment', {
  433. browsers: browsers
  434. });
  435. });
  436. feature(require('caniuse-db/features-json/css-image-set.json'), function(browsers) {
  437. return prefix('image-set', {
  438. props: ['background', 'background-image', 'border-image', 'mask', 'list-style', 'list-style-image', 'content', 'mask-image'],
  439. browsers: browsers
  440. });
  441. });
  442. writingMode = require('caniuse-db/features-json/css-writing-mode.json');
  443. feature(writingMode, {
  444. match: /a|x/
  445. }, function(browsers) {
  446. return prefix('writing-mode', {
  447. browsers: browsers
  448. });
  449. });
  450. feature(require('caniuse-db/features-json/css-cross-fade.json'), function(browsers) {
  451. return prefix('cross-fade', {
  452. props: ['background', 'background-image', 'border-image', 'mask', 'list-style', 'list-style-image', 'content', 'mask-image'],
  453. browsers: browsers
  454. });
  455. });
  456. readOnly = require('caniuse-db/features-json/css-read-only-write.json');
  457. feature(readOnly, function(browsers) {
  458. return prefix(':read-only', ':read-write', {
  459. selector: true,
  460. browsers: browsers
  461. });
  462. });
  463. feature(require('caniuse-db/features-json/text-emphasis.json'), function(browsers) {
  464. return prefix('text-emphasis', 'text-emphasis-position', 'text-emphasis-style', 'text-emphasis-color', {
  465. browsers: browsers
  466. });
  467. });
  468. grid = require('caniuse-db/features-json/css-grid.json');
  469. feature(grid, function(browsers) {
  470. prefix('display-grid', 'inline-grid', {
  471. props: ['display'],
  472. browsers: browsers
  473. });
  474. return prefix('grid-template-columns', 'grid-template-rows', 'grid-row-start', 'grid-column-start', 'grid-row-end', 'grid-column-end', 'grid-row', 'grid-column', {
  475. browsers: browsers
  476. });
  477. });
  478. feature(grid, {
  479. match: /a x/
  480. }, function(browsers) {
  481. return prefix('justify-items', 'grid-row-align', {
  482. browsers: browsers
  483. });
  484. });
  485. textSpacing = require('caniuse-db/features-json/css-text-spacing.json');
  486. feature(textSpacing, function(browsers) {
  487. return prefix('text-spacing', {
  488. browsers: browsers
  489. });
  490. });
  491. feature(require('caniuse-db/features-json/css-any-link.json'), function(browsers) {
  492. return prefix(':any-link', {
  493. selector: true,
  494. browsers: browsers
  495. });
  496. });
  497. }).call(this);