UI for Zipcoin Blue

at-rule.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 Prefixer = require('./prefixer');
  7. var AtRule = function (_Prefixer) {
  8. _inherits(AtRule, _Prefixer);
  9. function AtRule() {
  10. _classCallCheck(this, AtRule);
  11. return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
  12. }
  13. /**
  14. * Clone and add prefixes for at-rule
  15. */
  16. AtRule.prototype.add = function add(rule, prefix) {
  17. var prefixed = prefix + rule.name;
  18. var already = rule.parent.some(function (i) {
  19. return i.name === prefixed && i.params === rule.params;
  20. });
  21. if (already) {
  22. return undefined;
  23. }
  24. var cloned = this.clone(rule, { name: prefixed });
  25. return rule.parent.insertBefore(rule, cloned);
  26. };
  27. /**
  28. * Clone node with prefixes
  29. */
  30. AtRule.prototype.process = function process(node) {
  31. var parent = this.parentPrefix(node);
  32. for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  33. var _ref;
  34. if (_isArray) {
  35. if (_i >= _iterator.length) break;
  36. _ref = _iterator[_i++];
  37. } else {
  38. _i = _iterator.next();
  39. if (_i.done) break;
  40. _ref = _i.value;
  41. }
  42. var prefix = _ref;
  43. if (!parent || parent === prefix) {
  44. this.add(node, prefix);
  45. }
  46. }
  47. };
  48. return AtRule;
  49. }(Prefixer);
  50. module.exports = AtRule;