Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

old-selector.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. "use strict";
  2. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  3. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5. var OldSelector = /*#__PURE__*/function () {
  6. function OldSelector(selector, prefix) {
  7. this.prefix = prefix;
  8. this.prefixed = selector.prefixed(this.prefix);
  9. this.regexp = selector.regexp(this.prefix);
  10. this.prefixeds = selector.possible().map(function (x) {
  11. return [selector.prefixed(x), selector.regexp(x)];
  12. });
  13. this.unprefixed = selector.name;
  14. this.nameRegexp = selector.regexp();
  15. }
  16. /**
  17. * Is rule a hack without unprefixed version bottom
  18. */
  19. var _proto = OldSelector.prototype;
  20. _proto.isHack = function isHack(rule) {
  21. var index = rule.parent.index(rule) + 1;
  22. var rules = rule.parent.nodes;
  23. while (index < rules.length) {
  24. var before = rules[index].selector;
  25. if (!before) {
  26. return true;
  27. }
  28. if (before.includes(this.unprefixed) && before.match(this.nameRegexp)) {
  29. return false;
  30. }
  31. var some = false;
  32. for (var _iterator = _createForOfIteratorHelperLoose(this.prefixeds), _step; !(_step = _iterator()).done;) {
  33. var _step$value = _step.value,
  34. string = _step$value[0],
  35. regexp = _step$value[1];
  36. if (before.includes(string) && before.match(regexp)) {
  37. some = true;
  38. break;
  39. }
  40. }
  41. if (!some) {
  42. return true;
  43. }
  44. index += 1;
  45. }
  46. return true;
  47. }
  48. /**
  49. * Does rule contain an unnecessary prefixed selector
  50. */
  51. ;
  52. _proto.check = function check(rule) {
  53. if (!rule.selector.includes(this.prefixed)) {
  54. return false;
  55. }
  56. if (!rule.selector.match(this.regexp)) {
  57. return false;
  58. }
  59. if (this.isHack(rule)) {
  60. return false;
  61. }
  62. return true;
  63. };
  64. return OldSelector;
  65. }();
  66. module.exports = OldSelector;