clear.js 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. const parsers = require("../parsers");
  3. const property = "clear";
  4. module.exports.parse = (v, opt = {}) => {
  5. const { globalObject } = opt;
  6. if (v === "") {
  7. return v;
  8. }
  9. const value = parsers.parsePropertyValue(property, v, {
  10. globalObject,
  11. inArray: true
  12. });
  13. if (Array.isArray(value) && value.length === 1) {
  14. return parsers.resolveKeywordValue(value);
  15. } else if (typeof value === "string") {
  16. return value;
  17. }
  18. };
  19. module.exports.definition = {
  20. set(v) {
  21. v = parsers.prepareValue(v);
  22. if (parsers.hasVarFunc(v)) {
  23. this._setProperty(property, v);
  24. } else {
  25. const val = module.exports.parse(v, {
  26. globalObject: this._global
  27. });
  28. if (typeof val === "string") {
  29. const priority = this._priorities.get(property) ?? "";
  30. this._setProperty(property, val, priority);
  31. }
  32. }
  33. },
  34. get() {
  35. return this.getPropertyValue(property);
  36. },
  37. enumerable: true,
  38. configurable: true
  39. };
  40. module.exports.property = property;