CSSDocumentRule.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //.CommonJS
  2. var CSSOM = {
  3. CSSRule: require("./CSSRule").CSSRule,
  4. CSSRuleList: require("./CSSRuleList").CSSRuleList,
  5. MatcherList: require("./MatcherList").MatcherList
  6. };
  7. ///CommonJS
  8. /**
  9. * @constructor
  10. * @see https://developer.mozilla.org/en/CSS/@-moz-document
  11. * @deprecated This rule is a non-standard Mozilla-specific extension and is not part of any official CSS specification.
  12. */
  13. CSSOM.CSSDocumentRule = function CSSDocumentRule() {
  14. CSSOM.CSSRule.call(this);
  15. this.matcher = new CSSOM.MatcherList();
  16. this.cssRules = new CSSOM.CSSRuleList();
  17. };
  18. CSSOM.CSSDocumentRule.prototype = Object.create(CSSOM.CSSRule.prototype);
  19. CSSOM.CSSDocumentRule.prototype.constructor = CSSOM.CSSDocumentRule;
  20. Object.setPrototypeOf(CSSOM.CSSDocumentRule, CSSOM.CSSRule);
  21. Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "type", {
  22. value: 10,
  23. writable: false
  24. });
  25. //FIXME
  26. //CSSOM.CSSDocumentRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
  27. //CSSOM.CSSDocumentRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
  28. Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
  29. get: function() {
  30. var cssTexts = [];
  31. for (var i=0, length=this.cssRules.length; i < length; i++) {
  32. cssTexts.push(this.cssRules[i].cssText);
  33. }
  34. return "@-moz-document " + this.matcher.matcherText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
  35. }
  36. });
  37. //.CommonJS
  38. exports.CSSDocumentRule = CSSOM.CSSDocumentRule;
  39. ///CommonJS