grid-end.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function() {
  2. var Declaration, GridEnd,
  3. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4. hasProp = {}.hasOwnProperty;
  5. Declaration = require('../declaration');
  6. GridEnd = (function(superClass) {
  7. extend(GridEnd, superClass);
  8. function GridEnd() {
  9. return GridEnd.__super__.constructor.apply(this, arguments);
  10. }
  11. GridEnd.names = ['grid-row-end', 'grid-column-end', 'grid-row-span', 'grid-column-span'];
  12. GridEnd.prototype.check = function(decl) {
  13. return decl.value.indexOf('span') !== -1;
  14. };
  15. GridEnd.prototype.normalize = function(prop) {
  16. return prop.replace(/(-span|-end)/, '');
  17. };
  18. GridEnd.prototype.prefixed = function(prop, prefix) {
  19. if (prefix === '-ms-') {
  20. return prefix + prop.replace('-end', '-span');
  21. } else {
  22. return GridEnd.__super__.prefixed.call(this, prop, prefix);
  23. }
  24. };
  25. GridEnd.prototype.set = function(decl, prefix) {
  26. if (prefix === '-ms-') {
  27. decl.value = decl.value.replace(/span\s/i, '');
  28. }
  29. return GridEnd.__super__.set.call(this, decl, prefix);
  30. };
  31. return GridEnd;
  32. })(Declaration);
  33. module.exports = GridEnd;
  34. }).call(this);