backgroundImage.js 754 B

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