api.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "use strict";
  2. /*
  3. MIT License http://www.opensource.org/licenses/mit-license.php
  4. Author Tobias Koppers @sokra
  5. */
  6. // css base code, injected by the css-loader
  7. // eslint-disable-next-line func-names
  8. module.exports = function (cssWithMappingToString) {
  9. var list = []; // return the list of modules as css string
  10. list.toString = function toString() {
  11. return this.map(function (item) {
  12. var content = cssWithMappingToString(item);
  13. if (item[2]) {
  14. return "@media ".concat(item[2], " {").concat(content, "}");
  15. }
  16. return content;
  17. }).join("");
  18. }; // import a list of modules into the list
  19. // eslint-disable-next-line func-names
  20. list.i = function (modules, mediaQuery, dedupe) {
  21. if (typeof modules === "string") {
  22. // eslint-disable-next-line no-param-reassign
  23. modules = [[null, modules, ""]];
  24. }
  25. var alreadyImportedModules = {};
  26. if (dedupe) {
  27. for (var i = 0; i < this.length; i++) {
  28. // eslint-disable-next-line prefer-destructuring
  29. var id = this[i][0];
  30. if (id != null) {
  31. alreadyImportedModules[id] = true;
  32. }
  33. }
  34. }
  35. for (var _i = 0; _i < modules.length; _i++) {
  36. var item = [].concat(modules[_i]);
  37. if (dedupe && alreadyImportedModules[item[0]]) {
  38. // eslint-disable-next-line no-continue
  39. continue;
  40. }
  41. if (mediaQuery) {
  42. if (!item[2]) {
  43. item[2] = mediaQuery;
  44. } else {
  45. item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
  46. }
  47. }
  48. list.push(item);
  49. }
  50. };
  51. return list;
  52. };