CSSNestedDeclarations.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //.CommonJS
  2. var CSSOM = {
  3. CSSRule: require("./CSSRule").CSSRule,
  4. CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
  5. };
  6. // Use cssstyle if available
  7. try {
  8. CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
  9. } catch (e) {
  10. // ignore
  11. }
  12. ///CommonJS
  13. /**
  14. * @constructor
  15. * @see https://drafts.csswg.org/css-nesting-1/
  16. */
  17. CSSOM.CSSNestedDeclarations = function CSSNestedDeclarations() {
  18. CSSOM.CSSRule.call(this);
  19. this.__style = new CSSOM.CSSStyleDeclaration();
  20. this.__style.parentRule = this;
  21. };
  22. CSSOM.CSSNestedDeclarations.prototype = Object.create(CSSOM.CSSRule.prototype);
  23. CSSOM.CSSNestedDeclarations.prototype.constructor = CSSOM.CSSNestedDeclarations;
  24. Object.setPrototypeOf(CSSOM.CSSNestedDeclarations, CSSOM.CSSRule);
  25. Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "type", {
  26. value: 0,
  27. writable: false
  28. });
  29. Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "style", {
  30. get: function() {
  31. return this.__style;
  32. },
  33. set: function(value) {
  34. if (typeof value === "string") {
  35. this.__style.cssText = value;
  36. } else {
  37. this.__style = value;
  38. }
  39. }
  40. });
  41. Object.defineProperty(CSSOM.CSSNestedDeclarations.prototype, "cssText", {
  42. get: function () {
  43. return this.style.cssText;
  44. }
  45. });
  46. //.CommonJS
  47. exports.CSSNestedDeclarations = CSSOM.CSSNestedDeclarations;
  48. ///CommonJS