项目原始demo,不改动
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
To repozytorium jest zarchiwizowane. Możesz wyświetlać pliki i je sklonować, ale nie możesz do niego przepychać zmian lub otwierać zgłoszeń/Pull Requestów.
 
 
 
 

75 wiersze
3.0 KiB

  1. 'use strict';
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
  6. var Declaration = require('../declaration');
  7. var shorthand = require('./grid-shorthand');
  8. var GridTemplate = function (_Declaration) {
  9. _inherits(GridTemplate, _Declaration);
  10. function GridTemplate() {
  11. _classCallCheck(this, GridTemplate);
  12. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  13. }
  14. /**
  15. * Do not add prefix for unsupported value in IE
  16. */
  17. GridTemplate.prototype.check = function check(decl) {
  18. return decl.value.includes('/') && !decl.value.includes('[') && !decl.value.includes('"') && !decl.value.includes('\'');
  19. };
  20. /**
  21. * Translate grid-template to separate -ms- prefixed properties
  22. */
  23. GridTemplate.prototype.insert = function insert(decl, prefix, prefixes) {
  24. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  25. if (decl.parent.some(function (i) {
  26. return i.prop === '-ms-grid-rows';
  27. })) {
  28. return undefined;
  29. }
  30. var _shorthand$parseTempl = shorthand.parseTemplateShortcut(decl),
  31. templateRows = _shorthand$parseTempl[0],
  32. templateColumns = _shorthand$parseTempl[1];
  33. if (templateRows) {
  34. decl.cloneBefore({
  35. prop: '-ms-grid-rows',
  36. value: shorthand.changeRepeat(templateRows.join(''))
  37. });
  38. }
  39. if (templateColumns) {
  40. decl.cloneBefore({
  41. prop: '-ms-grid-columns',
  42. value: shorthand.changeRepeat(templateColumns.join(''))
  43. });
  44. }
  45. return decl;
  46. };
  47. return GridTemplate;
  48. }(Declaration);
  49. Object.defineProperty(GridTemplate, 'names', {
  50. enumerable: true,
  51. writable: true,
  52. value: ['grid-template']
  53. });
  54. module.exports = GridTemplate;