backgroundAttachment.js 773 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. const parsers = require("../parsers");
  3. module.exports.parse = function parse(v) {
  4. const keywords = ["fixed", "scroll", "local"];
  5. return parsers.parseKeyword(v, keywords);
  6. };
  7. module.exports.isValid = function isValid(v) {
  8. if (v === "") {
  9. return true;
  10. }
  11. return typeof module.exports.parse(v) === "string";
  12. };
  13. module.exports.definition = {
  14. set(v) {
  15. v = parsers.prepareValue(v, this._global);
  16. if (parsers.hasVarFunc(v)) {
  17. this._setProperty("background", "");
  18. this._setProperty("background-attachment", v);
  19. } else {
  20. this._setProperty("background-attachment", module.exports.parse(v));
  21. }
  22. },
  23. get() {
  24. return this.getPropertyValue("background-attachment");
  25. },
  26. enumerable: true,
  27. configurable: true
  28. };